-
Notifications
You must be signed in to change notification settings - Fork 99
[0804] Julia 会话支持符号计算 #3752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AXeonV
wants to merge
4
commits into
main
Choose a base branch
from
ty/0804
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−4
Open
[0804] Julia 会话支持符号计算 #3752
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # [0804] Julia 会话支持符号计算 | ||
|
|
||
| ## 如何测试 | ||
| - 打开 Julia 会话,使用如下命令安装 package: | ||
| ```julia | ||
| using Pkg | ||
| Pkg.add("Symbolics") | ||
| Pkg.add("Latexify") | ||
| Pkg.add("LaTeXStrings") | ||
| ``` | ||
|
|
||
| - 输入命令加载环境 packages: | ||
| ```julia | ||
| using Symbolics, Latexify, LaTeXStrings | ||
| ``` | ||
|
|
||
| - 分别复制粘贴以下代码并执行: | ||
| ```julia | ||
| @variables x | ||
| x^2 | ||
| ``` | ||
| 应输出一个渲染好的下x^2 | ||
|
Copilot marked this conversation as resolved.
Outdated
|
||
| ```julia | ||
| @variables a b c | ||
| formula = (a + b)^2 / c | ||
| ``` | ||
| 应输出一个渲染好的此单行公式 | ||
| ```julia | ||
| @variables a b | ||
| [a^2, b] | ||
| ``` | ||
| 应输出一个渲染好的列向量 | ||
| ```julia | ||
| @variables a b | ||
| (a^2, b) | ||
| ``` | ||
| 应输出一个渲染好的列向量 | ||
| ```julia | ||
| @variables a b c d | ||
| M = [a b; c d] | ||
| ``` | ||
| 应输出一个渲染好的矩阵 | ||
| ```julia | ||
| @variables a b | ||
| Dict(a => b) | ||
| ``` | ||
| 应输出一个矩阵形势的字典 | ||
|
Copilot marked this conversation as resolved.
Outdated
|
||
| ```julia | ||
| L"\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}" | ||
| ``` | ||
| 应输出一个渲染好的行内 latex 公式 | ||
| ```julia | ||
| @variables x | ||
| D = Differential(x) | ||
| expand_derivatives(D(sin(x) * x^2)) | ||
| ``` | ||
| 应输出一个渲染好的 $2x\sin(x) + x^2\cos(x)$ | ||
| ```julia | ||
| @variables x y | ||
| expr = (x^2 - y^2) / (x - y) | ||
| simplify(expr) | ||
| ``` | ||
| 应输出一个渲染好的 $x + y$ | ||
| ```julia | ||
| @variables x y | ||
| expr = (x + y)^2 | ||
| expand(expr) | ||
| ``` | ||
| 应输出一个渲染好的 $x^2 + 2xy + y^2$ | ||
| ```julia | ||
| 1 + 2 | ||
| ``` | ||
| 非符号计算,应输出一个普通的数字 3 | ||
| ```julia | ||
| [1, 2, 3] | ||
| ``` | ||
| 非符号计算,应输出一个普通的提示信息文本 | ||
|
|
||
| ## 2026/6/17 | ||
| ### What | ||
| 支持 Julia 会话的符号计算,可以直接在会话中生成公式,类似于 Python 的 SymPy | ||
|
|
||
| ### How | ||
| 1. 提升 `MoganJulia.jl` 交互式会话中 `text/latex` MIME 类型的匹配优先级,确保 `text/latex` 优先于 `text/html` / `text/markdown` 导出 | ||
| 2. 实现符号对象侦测器 `is_symbolic_object(x)`,通过动态反射检查并自适应对象的类型,并在非原生 LaTeX 格式的容器上自适应激活 `Latexify` 转换 | ||
| 3. 对输出的 LaTeX 文本进行统一化边界脱壳:自动过滤并剥离多余的 `$$`、`$`、`\[ \]` 或 `\( \)` 等外部数学边界符,对非 `\begin` 起始的代数公式两端注入标准的 `$\rmfamily{...}$` 包裹 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.