SuperAPI AI Directory

formula-normalizer

Writing & research

View repository

Updated 10-21 16:21

About this skill

Formula Normalizer

Overview

This skill provides two core functions: (1) mathematical formula format standardization and symbol consistency checking; (2) general template generation for classic algorithm comparison descriptions in dissertations. Through a systematic normalization process and structured templates, it ensures the professionalism and consistency of mathematical expressions in academic documents.

Workflow Decision Tree

用户请求处理
    ↓
识别请求类型(公式规范化 / 算法对比描述)
    ↓
┌─────────────────┴─────────────────┐
│                                   │
公式规范化                          算法对比描述
│                                   │
↓                                   ↓
分析文档中公式                      收集算法信息
↓                                   ↓
询问风格偏好                        生成结构化描述
↓                                   ↓
应用规范化规则                      输出学术级对比
↓                                   ↓
检查符号一致性                      质量检验
↓                                   ↓
返回规范化结果                      返回对比描述
└─────────────────┬─────────────────┘
                  ↓
            输出最终结果

Part 1: Formula Format Standardization

Applicable Scenarios

  • Normalization processing of mathematical formulas in Markdown documents
  • Unification of formula formats in dissertations
  • LaTeX syntax error checking and correction
  • Full-text mathematical symbol consistency checking

Core Rules

1. Standardization of Display Formulas

Format Requirements:

  • All independently displayed mathematical formulas (on a separate line, centered) must be wrapped in double dollar signs
  • Format:$$ ... $$
  • There must be appropriate blank lines before and after the formula

Prohibited Formats:

  • \[ ... \] - LaTeX display math
  • $$...$$(no spaces) - non-standard format
  • \begin{equation}...\end{equation} - LaTeX equation environment
  • Other non-standard LaTeX environments

Correct Example:

牛顿迭代法的迭代公式为:

$$
x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)} \tag{2}
$$

其中:$x_k$ 为第 $k$ 次迭代的近似解。

2. Standardization of Inline Formulas

Format Requirements:

  • All inline mathematical formulas (embedded in paragraph text) must be wrapped in single dollar signs
  • Format:$ ... $

Correct Example:

函数 $f(x)$ 在区间 $[a, b]$ 上连续。
当 $|x_{k+1} - x_k| < \varepsilon$ 时,算法收敛。

3. LaTeX Syntax Correctness

Requirements:

  • The LaTeX syntax inside formulas should remain correct
  • Including superscripts and subscripts, fractions, Greek letters, operators, etc.

Common Corrections:

  • Superscripts and subscripts:x^2 → x^{2}, x_i → x_{i}
  • Fractions:a/b → \frac{a}{b}
  • Greek letters:\alpha, \beta, \gamma etc.
  • Operators:\neq, \leq, \geq, \times etc.

4. Principle of Semantic Preservation

Requirements:

  • Preserve the semantics and content of the original text unchanged
  • Only modify the format, do not add or delete text
  • Do not rewrite sentences or adjust the meaning of formulas

Formula Style Modes

Before performing normalization, you must ask the user for their style preference:

Professional (Professional Style)

Characteristics:

  • Use complete LaTeX syntax
  • Include all necessary brackets and delimiters
  • Formula expressions are rigorous and standardized
  • Suitable for formal academic publications

Example:

$$
x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)}
$$

Concise (Concise Style)

Characteristics:

  • Simplify formula expressions
  • Remove redundant brackets and delimiters
  • Formula expressions are concise and intuitive
  • Suitable for technical documents and lecture notes

Example:

$$
x_{k+1} = x_k - f(x_k)/f'(x_k)
$$

Standard (Standard Style)

Characteristics:

  • Maintain the original style
  • Only perform format normalization
  • Do not change the way formulas are expressed
  • Suitable for general documents

Symbol Consistency Checking

Checking Dimensions

  1. Variable naming consistency

    • Unify variable naming throughout the text (such as x_i vs x_{i})
    • Unify superscript and subscript formats
    • Unified vector/matrix representation (e.g., \mathbf{x} vs \vec{x})
  2. Operator format consistency

    • Unified multiplication operator (\times vs *)
    • Unified division operator (\frac vs /)
    • Unified comparison operator (\leq vs <=)
  3. Greek letter consistency

    • Unified use of LaTeX commands (\alpha vs α)
    • Unified uppercase/lowercase format
    • Unified italic/upright usage
  4. Function naming consistency

    • Unified function representation (e.g., \sin vs sin)
    • Unified custom function format
    • Unified abbreviations and full names

Processing workflow

Phase 1: Document analysis

  1. Formula recognition

    • Identify all standalone display formulas
    • Identify all inline formulas
    • Identify mathematical expressions that are not properly wrapped
  2. Format check

    • Check whether the formula format complies with the specification
    • Identify non-standard formats
    • Check for LaTeX syntax errors
  3. Symbol statistics

    • Count variable usage frequency
    • Count operator usage
    • Count Greek letter usage

Phase 2: Style confirmation

Ask the user:

请问您希望采用哪种公式风格?
1. Professional(专业化)- 使用完整LaTeX语法,适合正式学术出版物
2. Concise(简洁化)- 简化公式表达,适合技术文档
3. Standard(标准)- 保持原文风格,仅进行格式规范化

Phase 3: Normalization application

  1. Format conversion

    • Convert non-standard formats to standard formats
    • Correct LaTeX syntax errors
    • Add necessary blank lines and separators
  2. Symbol unification

    • Unify variable naming format
    • Unify operator format
    • Unify Greek letter format
  3. Consistency check

    • Verify symbol consistency throughout the text
    • Identify inconsistent symbol usage
    • Provide unification suggestions

Phase 4: Result output

  1. Normalized document

    • Output the complete normalized document
    • Preserve the original semantics and content
  2. Modification report

    • List all modifications
    • Show before-and-after comparisons of modifications
    • Provide normalization statistics
  3. Consistency report

    • List symbol usage
    • Identify inconsistent symbols
    • Provide unification suggestions

Processing example

Input example

函数 f(x) = x^2 在区间 [a,b] 上连续。
牛顿迭代公式为:
\[
x_{k+1} = x_k - f(x_k)/f'(x_k)
\]
其中 x_k 为第 k 次迭代的近似解。

Output example (professional style)

函数 $f(x) = x^{2}$ 在区间 $[a,b]$ 上连续。
牛顿迭代公式为:

$$
x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)}
$$

其中:$x_k$ 为第 $k$ 次迭代的近似解。

Output example (concise style)

函数 $f(x) = x^2$ 在区间 $[a,b]$ 上连续。
牛顿迭代公式为:

$$
x_{k+1} = x_k - f(x_k)/f'(x_k)
$$

其中:$x_k$ 为第 $k$ 次迭代的近似解。

Part 2: Algorithm comparison description generation

Applicable scenarios

In the following chapters of master's/doctoral theses, a formal, structured, and comparable introduction to two or more basic algorithms/numerical methods/solution strategies is required:

  • Introduction - Introduce the research background and related methods
  • Research background - Explain commonly used methods in the field
  • Related work - Review and compare existing methods
  • Methodology - Describe the adopted methods in detail

Application fields:

  • Computational mechanics, control engineering, financial mathematics
  • Geophysics, biological modeling, energy systems
  • Underlying optimizers for machine learning, etc., and any discipline involving numerical computation

Core Features: Problem-oriented + Separate method descriptions + Formula support + Comparative summary

Input Elements

To generate a high-quality algorithm comparison description, the user needs to provide the following structured information:

Element Description Example
Research problem The specific numerical/computational problem to be solved "Solving the implicit discretized system of the steady-state heat conduction partial differential equation"
Nature of variables Emphasize that it iscontinuous-valued(real domain) solving "The state variable $u \in \mathbb{R}^n$ is a continuous field quantity"
List of methods to be described Clearly specify the names of the algorithms to be introduced (2–3 is appropriate) "Conjugate gradient method, Jacobi iteration method" or "Bisection method, Newton's method"
Whether formulas are needed Whether to include key formulas and symbol explanations "Yes, all formulas need to be numbered and accompanied by symbol annotations"
Structural preference Whether to require the "principle → formula → steps → comparison" process "Expand method by method, and compare them collectively at the end"

Output Specifications

The generated content must meet the following standards:

Language style

  • Formal, objective, and logically rigorous
  • Compliant with Chinese academic paper conventions
  • Use accurate academic terminology

Overall structure

  1. Opening paragraph

    • Clarify the background of the research problem
    • Explain the continuity characteristics
    • Introduce the necessity of the described methods
  2. Description of Method A

    • Paragraph expositionBasic principles and sources of ideas
    • Providecore formulas or iterative schemes(with numbering)
    • Immediately below the formulaprovidea symbol explanation table
    • Paragraph overviewKey implementation steps and termination conditions
  3. Description of Method B

    • Same structure as Method A
    • Can be extended to Method C
  4. Comparative analysis paragraph

    • Conduct an objective comparison from the following dimensions:
      • Convergence (global/local, order)
      • Computational complexity (cost per step, memory requirements)
      • Robustness (sensitivity to initial values, parameters, and noise)
      • Applicable prerequisites (such as smoothness, differentiability, monotonicity)
      • Suitability in the current application field

Mathematical expression

  • Use LaTeX format
  • Variables should have semantic definitions when they first appear
  • Avoid unexplained abbreviations (e.g., when "PDE" first appears, write "partial differential equation (Partial Differential Equation, PDE)")

Domain integration

  • Naturally combine method motivation with application scenarios
  • Avoid "method islands"
  • Reflect problem-driven motivation

Content structure template

在[研究领域]中,[具体问题,如"非线性系统的稳态响应计算"]通常归结为对连续变量 [变量符号] ∈ ℝⁿ 的求解任务,其数学形式常表现为[方程类型,如"非线性代数方程组 F(x) = 0"或"变分问题"]。针对此类问题,[方法A]与[方法B]作为两类具有代表性的数值策略,因其[各自优势],被广泛应用于[领域名称]的相关研究中。

[方法A名称]是一种[定性分类,如"基于区间收缩的确定性方法"或"基于梯度信息的一阶优化器"],其核心思想是[自然语言描述原理,可引用数学基础如介值定理、不动点原理、能量最小化等]。该方法特别适用于[说明适用场景,如"函数不可导但连续"或"大规模稀疏系统"]的情形。

[方法A]的关键更新规则/迭代公式如下:

$$
[公式]
\tag{1}
$$

其中:
- [符号₁]:[物理/数学含义];
- [符号₂]:[单位或约束条件];
- ⋯

其实现通常包含以下步骤:(1)[初始化,如设定初始区间或初值];(2)[主循环中的计算操作];(3)[收敛判据,如 ‖rₖ‖ < ε 或 |xₖ₊₁ − xₖ| < δ];(4)[输出结果或失败处理]。该方法具有[收敛性质,如"全局线性收敛"],其主要优势在于[鲁棒性/无需导数等],但[局限性,如"收敛速度慢"]。

相比之下,[方法B名称]则属于[另一类方法,如"基于局部近似的高阶方法"或"利用二阶信息的牛顿型算法"],其设计动机源于[思想来源,如"泰勒展开"、"KKT条件"等]。在[应用场景]中,当[前提条件,如"目标函数二阶可微"或"雅可比矩阵非奇异"]成立时,该方法能够显著提升求解效率。

[方法B]的迭代格式可表示为:

$$
[公式]
\tag{2}
$$

其中:
- [符号₁]:[说明];
- [符号₂]:[说明];
- ⋯

典型实施流程包括:(1)[初值选取策略];(2)[每步所需计算量,如函数值、梯度、Hessian];(3)[更新规则];(4)[收敛性监控]。在满足[理论假设]的前提下,该方法具备[收敛特性,如"局部超线性收敛"],但对[敏感因素,如初值质量、病态性]较为敏感。

综合而言,[方法A]与[方法B]在解决[研究问题]时呈现出明显的互补性。[方法A]以[优点]见长,适合[使用场景];而[方法B]则在[条件满足时]展现出[性能优势],但需承担[风险或成本]。因此,在实际工程或科研实践中,常采用[混合策略,如"外层用A保证收敛,内层用B加速"],以在**稳定性**与**效率**之间取得平衡。

Output example

Example: Bisection method vs Newton's method

在数值计算领域,非线性方程求根问题通常归结为对连续变量 $x \in \mathbb{R}$ 的求解任务,其数学形式常表现为非线性代数方程 $f(x) = 0$。针对此类问题,二分法与牛顿迭代法作为两类具有代表性的数值策略,因其各自的优势,被广泛应用于科学计算和工程应用的相关研究中。

二分法是一种基于区间收缩的确定性方法,其核心思想是利用连续函数的介值定理,通过不断缩小包含根的区间来逼近真实解。该方法特别适用于函数不可导但连续的情形,对函数的光滑性要求较低。

二分法的关键更新规则如下:

$$
[a_{k+1}, b_{k+1}] = 
\begin{cases}
[a_k, c_k] & \text{if } f(a_k) \cdot f(c_k) < 0 \\
[c_k, b_k] & \text{if } f(c_k) \cdot f(b_k) < 0
\end{cases}
\tag{1}
$$

其中:
- $[a_k, b_k]$ 为第 $k$ 次迭代的区间,满足 $f(a_k) \cdot f(b_k) < 0$;
- $c_k = \frac{a_k + b_k}{2}$ 为区间中点;
- $f(\cdot)$ 为目标函数。

其实现通常包含以下步骤:(1)选取初始区间 $[a_0, b_0]$,确保函数在区间端点异号;(2)计算区间中点 $c_k$ 及其函数值 $f(c_k)$;(3)根据函数值符号更新区间;(4)判断收敛条件(如 $|b_k - a_k| < \varepsilon$ 或 $|f(c_k)| < \delta$),若满足则终止,否则继续迭代。该方法具有全局线性收敛性,其主要优势在于鲁棒性强、无需导数信息,但收敛速度较慢,每次迭代仅将区间长度减半。

相比之下,牛顿迭代法则是一种基于局部线性化思想的高阶数值方法,适用于函数光滑且导数可计算的情形。其核心在于利用函数在当前近似点处的一阶泰勒展开构造切线,并以切线与横轴的交点作为下一轮迭代的估计值。在车辆动力学中,当涉及如纵向加速度平衡、稳态转向角求解等可导非线性方程时,牛顿法能显著提升收敛效率。

牛顿迭代法的迭代公式为:

$$
x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)}
\tag{2}
$$

其中:
- $x_k$ 为第 $k$ 次迭代的近似解;
- $f(x_k)$ 为函数在 $x_k$ 处的取值;
- $f'(x_k)$ 为函数在 $x_k$ 处的一阶导数,且要求 $f'(x_k) \neq 0$。

该方法的关键步骤包括:(1)选取初始猜测值 $x_0$,通常基于物理先验知识(如车辆稳态运行工况下的合理参数范围);(2)在每一步迭代中计算函数值 $f(x_k)$ 及其导数 $f'(x_k)$;(3)利用公式 (2) 更新近似解;(4)判断收敛条件(如 $|x_{k+1} - x_k| < \varepsilon$ 或 $|f(x_{k+1})| < \delta$),若满足则终止,否则继续迭代。在函数 $f$ 二阶连续可导且初值 $x_0$ 充分接近真实根的条件下,牛顿法具有局部二次收敛性,即误差平方级衰减,远快于二分法。

综合而言,二分法与牛顿迭代法在解决非线性方程求根问题时呈现出明显的互补性。二分法以全局收敛和鲁棒性见长,适合初值未知或函数性质复杂的场景;而牛顿法则在初值质量良好且函数光滑时展现出超线性收敛优势,但需承担对初值敏感和导数计算成本的风险。因此,在实际工程或科研实践中,常采用混合策略(如外层用二分法保证收敛,内层用牛顿法加速),以在稳定性与效率之间取得平衡。

Quick customization keyword replacement table

Placeholder Replaceable content example
[研究领域] Computational fluid dynamics, structural health monitoring, quantitative finance, neural dynamics
[研究问题] Nonlinear equation root finding, unconstrained optimization, linear system solving, eigenvalue computation
[变量性质] Continuous state vector, real-valued control parameters, spatiotemporal field functions
[方法A/B] Bisection method / Newton's method; gradient descent / conjugate gradient; explicit Euler / implicit Runge-Kutta
[收敛性] Global linear convergence, local quadratic convergence, Q-superlinear convergence, convergence only under convex conditions

Notes and Best Practices

  • Terminological accuracy: Distinguish similar concepts (e.g., "binary search" for discrete arrays vs. "bisection method" for continuous root finding)
  • Rigorous convergence statements: Clarify that "global convergence" requires additional conditions (such as convexity, Lipschitz continuity), and avoid overpromising
  • Domain-relevant techniques: When describing the motivation for a method, add a sentence of domain context, for example: "In battery management systems, because the open-circuit voltage-state of charge mapping often exhibits nonsmooth characteristics, the bisection method becomes a reliable choice"
  • Extensibility: This template can be easily extended to a three-method comparison; simply copy the "Method Description" module
  • Avoid absolute superiority or inferiority: Emphasize that "applicable conditions determine performance" rather than "Method A is superior to Method B"

Resources

references/

These reference files contain detailed implementation guidelines, specific rules, and examples, and should be consulted as needed when performing normalization tasks.