<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://guoj.org/feed.xml" rel="self" type="application/atom+xml" /><link href="https://guoj.org/" rel="alternate" type="text/html" /><updated>2026-11-29T12:23:21+00:00</updated><id>https://guoj.org/feed.xml</id><title type="html">Jing Guo | 郭靖</title><subtitle>Personal homepage featuring research, writings, and professional information</subtitle><author><name>Jing Guo</name><email>dev.guoj@gmail.com</email></author><entry><title type="html">Stanford CS336 Lecture 1: Overview and Tokenization</title><link href="https://guoj.org/stanford-cs336-lecture-one.html" rel="alternate" type="text/html" title="Stanford CS336 Lecture 1: Overview and Tokenization" /><published>2026-11-07T00:00:00+00:00</published><updated>2026-11-07T00:00:00+00:00</updated><id>https://guoj.org/stanford-cs336-lecture-one</id><content type="html" xml:base="https://guoj.org/stanford-cs336-lecture-one.html"><![CDATA[<p>Everything in this blog post was first written by hand, and then converted into Markdown blog format by LLM. I used it for my learning and studies.</p>

<h2 id="small-versus-large-models">Small versus large models</h2>

<ol>
  <li>Attention’s share of floating-point operations drops from 35% to 17% when going from 760 million to 170 billion parameters, whereas the share for multilayer perceptrons goes from 44% to 80%.</li>
  <li>Behavior emerges when the number of training floating-point operations is around <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>10</mn><mn>22</mn></msup></mrow><annotation encoding="application/x-tex">10^{22}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span></span></span></span></span></span></span></span> or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>10</mn><mn>24</mn></msup></mrow><annotation encoding="application/x-tex">10^{24}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">24</span></span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>

<h3 id="what-from-cs336-transfers-to-frontier-models">What from CS336 transfers to frontier models?</h3>

<ol>
  <li><strong>Mechanics.</strong> How things work (for example, the Transformer).</li>
  <li><strong>Mindset.</strong> Squeezing the most out of hardware and taking scaling seriously.</li>
  <li><strong>Intuitions.</strong> Which data and modeling decisions yield good accuracy.</li>
</ol>

<h3 id="the-bitter-lesson">The bitter lesson</h3>

<ul>
  <li><strong>Wrong interpretation.</strong> Scaling is all that matters, and algorithms do not matter.</li>
  <li><strong>Right interpretation.</strong> Algorithms that scale are what matter.</li>
</ul>

<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext>Accuracy</mtext><mo>=</mo><mtext>Efficiency</mtext><mo>×</mo><mtext>Resources</mtext></mrow><annotation encoding="application/x-tex">\text{Accuracy} = \text{Efficiency} \times \text{Resources}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">Accuracy</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">Efficiency</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord">Resources</span></span></span></span></span></span>

<p>Efficiency is more important at larger scales.</p>

<h2 id="current-language-model-landscape">Current language model landscape</h2>

<ul>
  <li><strong>Pre-neural / 2010s.</strong> N-gram language models.</li>
  <li><strong>Neural (2010s).</strong> Long short-term memory, sequence to sequence, Adam, attention, Transformer, and mixture of experts.</li>
  <li><strong>Early foundation models (late 2010s).</strong> ELMo, BERT, and T5.</li>
  <li><strong>Scaling (2020s).</strong> GPT-2 and GPT-3, PaLM, Chinchilla, and scaling laws.</li>
  <li>Open models …</li>
</ul>

<p>The fundamentals are the same (attention, kernels, and optimization). The specifications are different (longer context and inference efficiency).</p>

<h2 id="basics">Basics</h2>

<ul>
  <li><strong>Goal.</strong> Train a basic language model.</li>
  <li><strong>Components.</strong> Tokenization, model architecture, and training.</li>
</ul>

<h3 id="tokenization">Tokenization</h3>

<p>A tokenizer converts between raw inputs (bytes) and sequences of integers (tokens).</p>

<ul>
  <li><strong>Popular approach.</strong> Byte-pair encoding (BPE).</li>
  <li><strong>Intuition.</strong> Break input into frequently occurring chunks.</li>
  <li><strong>Efficiency.</strong> Reduce context length (1,000 to 250 bytes). Adaptive computation.</li>
  <li><strong>The dream.</strong> A tokenizer-free model architecture.</li>
</ul>

<h3 id="model-architecture">Model architecture</h3>

<p><strong>Starting point.</strong> The original Transformer from 2017.</p>

<h4 id="refinements">Refinements</h4>

<ul>
  <li><strong>Activations.</strong> Rectified linear unit and Swish gated linear unit.</li>
  <li><strong>Position embeddings.</strong> Sinusoidal and rotary position embeddings.</li>
  <li><strong>Normalization.</strong> Layer normalization, root mean square normalization, query-key normalization, and pre-normalization versus post-normalization.</li>
  <li><strong>Attention.</strong> Full, sparse or local attention, group-query attention (GQA), and multi-head latent attention (MLA).</li>
  <li><strong>Recurrence, state-space models, and linear attention.</strong> Mamba and Gated DeltaNet.</li>
  <li><strong>Multilayer perceptrons.</strong> Dense and mixture of experts.</li>
  <li><strong>Shape.</strong> Hidden dimension, depth, number of heads, and number of experts.</li>
</ul>]]></content><author><name>Jing Guo</name><email>dev.guoj@gmail.com</email></author><summary type="html"><![CDATA[Study notes on Stanford CS336 Lecture 1 covering scaling, the bitter lesson, the language model landscape, tokenization, and Transformer refinements.]]></summary></entry><entry><title type="html">Solve, Verify, Correct – An IMO Problem-Solving Pipeline</title><link href="https://guoj.org/imo-math-agent.html" rel="alternate" type="text/html" title="Solve, Verify, Correct – An IMO Problem-Solving Pipeline" /><published>2026-02-12T00:00:00+00:00</published><updated>2026-02-12T00:00:00+00:00</updated><id>https://guoj.org/imo-math-agent</id><content type="html" xml:base="https://guoj.org/imo-math-agent.html"><![CDATA[<div class="callout">
  <p>The code is available at <a href="https://github.com/guojing0/imo-math-agent"><code class="language-plaintext highlighter-rouge">guojing0/imo-math-agent</code></a>. Contributions and feedback are welcome!</p>
</div>

<p>Last September, Yichen Huang and Lin F. Yang published a paper called “<em><a href="https://arxiv.org/abs/2507.15855">Winning Gold at IMO 2025 with a Model-Agnostic Verification-and-Refinement Pipeline</a></em>” (thanks to Prof. <a href="https://wenda302.github.io/">Wenda Li</a> for pointing me to this paper!), where they design a model-agnostic verification-and-refinement pipeline using then-frontier models (Gemini 2.5 Pro, Grok 4, and GPT 5) to correctly solve 5 out of the 6 problems from IMO 2025. What makes this interesting is that the baseline accuracies of these models, when selecting the best out of 32 candidate solutions, are all below 40%.</p>

<p>Last October, I was fortunate to be selected for Cohere Labs’ <a href="https://cohere.com/research/grants">Catalyst Grant Program</a> with 500 USD in credits. It seems like a great opportunity to replicate and improve this pipeline, and to see how Cohere’s Command models perform on IMO-level problems.</p>

<p>With the help of both Claude Code and Codex, I implemented the agent system described in the paper and also made a few improvements along the way. If you want to dive into the code directly, check out the repo <a href="https://github.com/guojing0/imo-math-agent"><code class="language-plaintext highlighter-rouge">guojing0/imo-math-agent</code></a>.</p>

<h2 id="architecture">Architecture</h2>

<p>This system has two core components: A <em>solver</em> that proposes and revises solutions, and a <em>verifier</em> that checks the proof. It loops until the verifier returns 5 consecutive valid verdicts (in this implementation, which you can configure yourself), or gives up after too many repeated errors.</p>

<p>Why is this <strong>loop</strong> so important? A model may produce correct algebra and notation, yet may still use hand-wavy reasoning or plausible-looking steps that hide errors. An answer with only one single pass gives no control over how and if the errors are detected, let alone correcting them. This iterative process makes the internal state explicit, with candidate solutions, verifier “bug reports”, and streak counters. It then keeps refining the proof until it is mathematically sound.</p>

<p>Here is how the paper shows the architecture:</p>

<p><img src="/images/imo-agent-figure.png" alt="pipeline" /></p>

<p>Or if you prefer a text description:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Problem
  |
  v
[1] Initial exploration
  |
  v
[2] Self-improvement
  |
  v
[3] Verification
  |
  +-- Valid? -&gt; Increment streak counter
  |                   |
  |                   +-- 5 consecutive passes? -&gt; SUCCESS
  |
  +-- Invalid? -&gt; Bug Report -&gt; [4] Correction -&gt; back to [3]
                                   |
                                   +-- 10 consecutive errors? -&gt; FAILURE
</code></pre></div></div>

<p>In the <a href="https://github.com/lyang36/IMO25">reference implementation</a>, the authors use the same model for both the solver and the verifier. My first improvement is that you can use different models for each role, even from different providers! This lets you pick a creative model for solving and a strict one for verification.</p>

<h3 id="how-to-verify">How to verify?</h3>

<p>Getting verification right is really important and interesting: A loose verifier will pass broken proofs, while an over-strict one will reject correct solutions. To balance this, the verification happens in two steps: First, the verifier generates a detailed log, acting as an IMO grader performing a step-by-step audit of the proof. Second, a follow-up call distills that log into a binary yes-or-no verdict.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Step 1: Full verification log
</span><span class="n">verification_log</span> <span class="o">=</span> <span class="n">self</span><span class="p">.</span><span class="n">verifier_backend</span><span class="p">.</span><span class="nf">generate</span><span class="p">(</span>
    <span class="n">system_prompt</span><span class="o">=</span><span class="n">VERIFICATION_SYSTEM_PROMPT</span><span class="p">,</span>
    <span class="n">user_prompt</span><span class="o">=</span><span class="n">verification_prompt</span><span class="p">,</span>
    <span class="n">temperature</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span>
<span class="p">)</span>

<span class="c1"># Step 2: Binary distillation
</span><span class="n">check_prompt</span> <span class="o">=</span> <span class="p">(</span>
    <span class="sh">'</span><span class="s">Response in </span><span class="sh">"</span><span class="s">yes</span><span class="sh">"</span><span class="s"> or </span><span class="sh">"</span><span class="s">no</span><span class="sh">"</span><span class="s">. </span><span class="sh">'</span>
    <span class="sh">"</span><span class="s">Is the following statement saying the solution is correct, </span><span class="sh">"</span>
    <span class="sh">"</span><span class="s">or does not contain critical error or a major justification gap?</span><span class="se">\n\n</span><span class="sh">"</span>
    <span class="sa">f</span><span class="sh">"</span><span class="si">{</span><span class="n">verification_log</span><span class="si">}</span><span class="sh">"</span>
<span class="p">)</span>
<span class="n">check_response</span> <span class="o">=</span> <span class="n">self</span><span class="p">.</span><span class="n">verifier_backend</span><span class="p">.</span><span class="nf">generate</span><span class="p">(</span>
    <span class="n">system_prompt</span><span class="o">=</span><span class="sh">""</span><span class="p">,</span>
    <span class="n">user_prompt</span><span class="o">=</span><span class="n">check_prompt</span><span class="p">,</span>
    <span class="n">temperature</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span>
<span class="p">)</span>
</code></pre></div></div>

<p>This two-phase approach lets the model reason deeply in the first pass and make a clear judgment call in the second.</p>

<h3 id="walkthrough-of-the-solving-process">Walkthrough of the solving process</h3>

<p>I will present here how the agent will attack a problem end to end:</p>

<ol>
  <li><strong>Initial exploration</strong>: The solver receives the problem with instructions to produce a structured response: A summary with a verdict and method sketch, followed by a full detailed solution. A temperature of 0.7 lets the model explore creative approaches without being too stoic.</li>
  <li><strong>Self-improvement</strong>: The agent then feeds the initial solution back to itself with a self-improvement prompt. This allows it to catch obvious mistakes and weak steps.</li>
  <li><strong>Verification</strong>: The detailed solution, after extraction from the structured output, then goes to the verifier. It will then walk through the proof step by step, producing a verification log.</li>
  <li><strong>Correction</strong>: The solver receives the original problem (Step 1), its proposed solution (Step 2), and the bug report (Step 3), and uses all of this context to produce a corrected proof.</li>
  <li><strong>Final step</strong>: The corrected solution goes back to verification. If it passes, the streak counter increments. After 5 consecutive passes, we declare success!</li>
</ol>

<h2 id="an-example-run">An example run!</h2>

<p>Once you have followed the setup in the <a href="https://github.com/guojing0/imo-math-agent/blob/master/README.md">README.md</a>, you can run:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>uv run imo-agent example_problem.txt <span class="nt">--backend</span> cohere
</code></pre></div></div>

<p>It will ask the agent system (Cohere’s default choice is <a href="https://docs.cohere.com/v2/docs/command-a-reasoning"><code class="language-plaintext highlighter-rouge">command-a-reasoning-08-2025</code></a>) to solve the problem in <code class="language-plaintext highlighter-rouge">example_problem.txt</code>, which is to use 3, 3, 7, 7 to make 24 in <a href="https://en.wikipedia.org/wiki/24_(puzzle)">the 24 puzzle</a>. I learned about this specific one from middle school!</p>

<p>You would see something like the following (after I removed <code class="language-plaintext highlighter-rouge">httpx</code> logs):</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;</span> uv run imo-agent example_problem.txt <span class="nt">--backend</span> cohere
2026-02-12 22:53:15,058 - imo_math_agent.cli - INFO - Solver Backend: cohere, Model: default
2026-02-12 22:53:15,225 - imo_math_agent.cli - INFO - <span class="o">==========</span> Full Attempt 1/10 <span class="o">==========</span>
2026-02-12 22:53:15,225 - imo_math_agent.agent - INFO - Starting solution process...
2026-02-12 22:53:15,225 - imo_math_agent.agent - INFO - Generating initial solution...
2026-02-12 22:54:27,871 - imo_math_agent.agent - INFO - Self-improving solution...
2026-02-12 22:54:51,653 - imo_math_agent.agent - INFO - Initial verification valid: True
2026-02-12 22:54:51,654 - imo_math_agent.agent - INFO - Iteration 1/20 - Correct streak: 1, Errors: 0
2026-02-12 22:55:05,367 - imo_math_agent.agent - INFO - Solution verified as valid. Streak: 2
2026-02-12 22:55:05,369 - imo_math_agent.agent - INFO - Iteration 2/20 - Correct streak: 2, Errors: 0
2026-02-12 22:55:16,154 - imo_math_agent.agent - INFO - Solution verified as valid. Streak: 3
2026-02-12 22:55:16,154 - imo_math_agent.agent - INFO - Iteration 3/20 - Correct streak: 3, Errors: 0
2026-02-12 22:55:32,010 - imo_math_agent.agent - INFO - Solution verified as valid. Streak: 4
2026-02-12 22:55:32,010 - imo_math_agent.agent - INFO - Iteration 4/20 - Correct streak: 4, Errors: 0
2026-02-12 22:55:45,233 - imo_math_agent.agent - INFO - Solution verified as valid. Streak: 5
2026-02-12 22:55:45,234 - imo_math_agent.agent - INFO - Solution verified 5 <span class="nb">times </span>consecutively. SUCCESS.
2026-02-12 22:55:45,234 - imo_math_agent.cli - INFO - Found a correct solution!


FINAL SOLUTION:

<span class="k">**</span>1. Summary<span class="k">**</span>

<span class="k">**</span>a. Verdict:<span class="k">**</span>
I have successfully solved the problem. The final answer is <span class="se">\b</span>oxed<span class="o">{(</span>3 + <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">})</span> <span class="se">\t</span>imes 7 <span class="o">=</span> 24<span class="o">}</span><span class="nb">.</span>

<span class="k">**</span>b. Method Sketch:<span class="k">**</span>
The solution leverages division and addition to create a fraction that, when multiplied by the remaining number, yields 24. Key steps include:
1. <span class="k">**</span>Division:<span class="k">**</span> Use one 3 and one 7 to form <span class="se">\(</span> <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">}</span> <span class="se">\)</span><span class="nb">.</span>
2. <span class="k">**</span>Addition:<span class="k">**</span> Combine the remaining 3 with <span class="se">\(</span> <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">}</span> <span class="se">\)</span> to obtain <span class="se">\(</span> <span class="se">\f</span>rac<span class="o">{</span>24<span class="o">}{</span>7<span class="o">}</span> <span class="se">\)</span><span class="nb">.</span>
3. <span class="k">**</span>Multiplication:<span class="k">**</span> Scale <span class="se">\(</span> <span class="se">\f</span>rac<span class="o">{</span>24<span class="o">}{</span>7<span class="o">}</span> <span class="se">\)</span> by the final 7 to reach 24.
This approach ensures all numbers are used exactly once, adhering to the 24 Game rules.

<span class="k">**</span>2. Detailed Solution<span class="k">**</span>

To form 24 using the numbers 3, 3, 7, and 7 exactly once, follow this sequence of operations:

1. <span class="k">**</span>Divide 3 by 7<span class="k">**</span>:
   <span class="se">\[</span>
   <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">}</span>
   <span class="se">\]</span>
   This uses one instance of 3 and one instance of 7.

2. <span class="k">**</span>Add the result to the remaining 3<span class="k">**</span>:
   <span class="se">\[</span>
   3 + <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">}</span> <span class="o">=</span> <span class="se">\f</span>rac<span class="o">{</span>21<span class="o">}{</span>7<span class="o">}</span> + <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">}</span> <span class="o">=</span> <span class="se">\f</span>rac<span class="o">{</span>24<span class="o">}{</span>7<span class="o">}</span>
   <span class="se">\]</span>
   This combines the second 3 with the fraction from step 1.

3. <span class="k">**</span>Multiply by the final 7<span class="k">**</span>:
   <span class="se">\[</span>
   <span class="se">\f</span>rac<span class="o">{</span>24<span class="o">}{</span>7<span class="o">}</span> <span class="se">\t</span>imes 7 <span class="o">=</span> 24
   <span class="se">\]</span>
   The remaining 7 cancels the denominator, yielding 24.

<span class="k">**</span>Final Expression<span class="k">**</span>:
<span class="se">\[</span>
<span class="se">\l</span>eft<span class="o">(</span>3 + <span class="se">\f</span>rac<span class="o">{</span>3<span class="o">}{</span>7<span class="o">}</span><span class="se">\r</span>ight<span class="o">)</span> <span class="se">\t</span>imes 7 <span class="o">=</span> 24
<span class="se">\]</span>

All numbers <span class="o">(</span>3, 3, 7, 7<span class="o">)</span> are used exactly once, and the arithmetic operations strictly follow order of operations <span class="o">(</span>division before addition, <span class="k">then </span>multiplication<span class="o">)</span><span class="nb">.</span> The solution is valid and satisfies the 24 Game constraints.
</code></pre></div></div>

<h2 id="lessons-learned-and-whats-next">Lessons learned and what’s next?</h2>

<ol>
  <li><em>Verifying is harder than solving</em>: Building a good solver is relatively straightforward: In a nutshell, you prompt an LLM to think hard. Building a verifier that reliably distinguishes a correct proof from a plausible-sounding wrong one is a much harder problem.</li>
  <li><em>Temperature tuning matters more than I thought</em>: Setting the verifier to 0.1 and the solver to 0.7 turns out to work well. I experimented with other values, and kept coming back to this combination.</li>
</ol>

<p>For next steps, there are a few directions that I am excited about:</p>

<ol>
  <li><em>Code execution for numeric checks</em>: Letting the agent run code to verify computational claims, rather than only reasoning about them.</li>
  <li><em>Fine-tuning</em>: I was also grateful to receive the <a href="https://thinkingmachines.ai/blog/tinker-research-and-teaching-grants/">Tinker Research Grant</a>, so fine-tuning dedicated solver and verifier models is a natural next step for improving accuracy.</li>
  <li><em>Tool-use</em>: Connecting the agent to symbolic algebra systems, automated theorem provers, and proof assistants like Lean and Coq, could also extend its reach to problems that demand both calculation and reasoning.</li>
</ol>]]></content><author><name>Jing Guo</name><email>dev.guoj@gmail.com</email></author><summary type="html"><![CDATA[Implementing and extending a model-agnostic solver-verifier pipeline for IMO-level mathematics problems with multi-provider support.]]></summary></entry><entry><title type="html">Algorithmic Improvements of Dynamical Systems for SageMath - Google Summer of Code 2023</title><link href="https://guoj.org/second-gsoc.html" rel="alternate" type="text/html" title="Algorithmic Improvements of Dynamical Systems for SageMath - Google Summer of Code 2023" /><published>2023-08-25T00:00:00+00:00</published><updated>2023-08-25T00:00:00+00:00</updated><id>https://guoj.org/second-gsoc</id><content type="html" xml:base="https://guoj.org/second-gsoc.html"><![CDATA[<p>This summer, I worked on a Google Summer of Code (GSoC) project to <em>improve height functionality in the context of dynamical systems</em> for <a href="https://www.sagemath.org/">SageMath</a>. I would like to thank my mentors <a href="https://mathstat.slu.edu/~hutzba/">Prof. Ben Hutz</a> and <a href="https://math.washington.edu/people/alexander-galarraga">Alexander Galarraga</a> for helpful meetings and email exchanges.</p>

<p>You can see my commits on <a href="https://github.com/search?q=repo%3Asagemath%2Fsage+jing+guo&amp;type=commits&amp;s=committer-date&amp;o=desc">GitHub</a>.</p>

<h2 id="is-it-important-and-useful-or-why-should-i-care">Is it important and useful, or why should I care?</h2>

<p>Height functions allow mathematicians to quantify the complexity of mathematical objects, such as rational points or the size of solutions to Diophantine equations in Diophantine geometry.</p>

<p>For instance, the <em>classical</em> or <em>naive height</em> over the rational numbers is the maximum of the numerators and denominators of the coordinates. As an example, the height of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mn>3</mn><mi mathvariant="normal">/</mi><mn>9</mn><mo separator="true">,</mo><mn>1</mn><mi mathvariant="normal">/</mi><mn>2</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(3/9, 1/2)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">3/9</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">1/2</span><span class="mclose">)</span></span></span></span> is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn></mrow><annotation encoding="application/x-tex">3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span>.</p>

<p>For interested readers, <a href="https://www.cambridge.org/core/books/heights-in-diophantine-geometry/4117673141D14050628601C428E8748D#fndtn-information"><em>Heights in Diophantine Geometry</em></a> by Enrico Bombieri is really helpful.</p>

<h2 id="what-have-i-done">What have I done?</h2>

<p>I contributed to 5 Pull Requests (PRs) in two different components (algebraic geometry and dynamics). Each ticket represents a separate task and contains the implementation, tests, and documentation:</p>

<ul>
  <li><a href="https://github.com/sagemath/sage/pull/35778">#35778: Return the points in the ring of integers after renormalization</a></li>
</ul>

<p>The <code class="language-plaintext highlighter-rouge">points_of_bounded_height</code> function in <code class="language-plaintext highlighter-rouge">proj_bdd_height.py</code> now returns correct results after renormalization by scaling, if in the ring of integers. We achieve this by introducing a new function <code class="language-plaintext highlighter-rouge">ZZ_points_of_bounded_height</code>.</p>

<ul>
  <li><a href="https://github.com/sagemath/sage/pull/35809">#35809: Ensure GCD in <code class="language-plaintext highlighter-rouge">normalize_coordinates</code> for projective morphisms</a></li>
</ul>

<p>This PR aims to fix the issue <a href="https://github.com/sagemath/sage/issues/35797">#35797</a>. Before the fix, the following code would fail:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sage: R.&lt;x&gt; = QQ[]
sage: K.&lt;a&gt; = NumberField(3*x^2 + 1)
sage: P.&lt;z,w&gt; = ProjectiveSpace(K, 1)
sage: f = DynamicalSystem_projective([a*(z^2 + w^2), z*w])
sage: f.normalize_coordinates(); f
</code></pre></div></div>

<p>Now it returns the correct result:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Dynamical System of Projective Space of dimension 1 over
Number Field in a with defining polynomial 3*x^2 + 1
Defn: Defined on coordinates by sending (z : w) to
    ((-3/2*a + 1/2)*z^2 + (-3/2*a + 1/2)*w^2 : (-3/2*a - 3/2)*z*w)
</code></pre></div></div>

<p>It is achieved via considering the number-field case separately, when clearing the denominators from the coefficients.</p>

<ul>
  <li><a href="https://github.com/sagemath/sage/pull/36000">#36000: New functions is_chebyshev and is_Lattes for one dimensional projective dynamical systems</a></li>
</ul>

<p>This PR carries the work and fixes <a href="https://github.com/sagemath/sage/issues/28292">#28292</a>, implementing John W. Milnor’s “On Lattès Maps”.</p>

<ul>
  <li><a href="https://github.com/sagemath/sage/pull/35998">#35998: Fix <code class="language-plaintext highlighter-rouge">preperiodic_points</code> function over rings</a></li>
</ul>

<p>This PR aims to fix <a href="https://github.com/sagemath/sage/issues/34095">#34095</a>.</p>

<ul>
  <li><a href="https://github.com/sagemath/sage/pull/35967">#35967: Generalize Wells’ algorithm for computing the canonical height of a projective point</a></li>
</ul>

<p>We aim to implement Ben Hutz’s generalization of Wells’ algorithm from “Computing the Canonical Height of a Point in Projective Space”.</p>

<h2 id="what-happens-after-the-coding-period">What happens after the coding period?</h2>

<p>After the official coding period, I hope to continue to contribute to open-source software and SageMath.</p>]]></content><author><name>Jing Guo</name><email>dev.guoj@gmail.com</email></author><summary type="html"><![CDATA[Summary of Google Summer of Code 2023 contributions to SageMath: height functions, normalize_coordinates, Lattes maps, Chebyshev polynomials, and preperiodic points.]]></summary></entry><entry><title type="html">Improve Height Functionality for SageMath - Google Summer of Code 2022</title><link href="https://guoj.org/sage-gsoc.html" rel="alternate" type="text/html" title="Improve Height Functionality for SageMath - Google Summer of Code 2022" /><published>2022-09-06T00:00:00+00:00</published><updated>2022-09-06T00:00:00+00:00</updated><id>https://guoj.org/sage-gsoc</id><content type="html" xml:base="https://guoj.org/sage-gsoc.html"><![CDATA[<p>This summer, I worked on a Google Summer of Code (GSoC) project to <em>improve height functionality</em> for <a href="https://www.sagemath.org/">SageMath</a>. I would like to thank my mentors <a href="https://mathstat.slu.edu/~hutzba/">Prof. Ben Hutz</a> and <a href="https://math.washington.edu/people/alexander-galarraga">Alexander Galarraga</a> for helpful meetings and email exchanges. I would also like to thank <a href="https://math.okstate.edu/people/fili/">Prof. Paul Fili</a> for teaching me the basics of the Arakelov-Zhang pairing.</p>

<p>You can see my commits on <a href="https://github.com/sagemath/sage/search?q=jing+guo&amp;type=commits">GitHub</a>.</p>

<h2 id="is-it-important-and-useful-or-why-should-i-care">Is it important and useful, or why should I care?</h2>

<p>Height functions allow mathematicians to quantify the complexity of mathematical objects, such as rational points or the size of solutions to Diophantine equations in Diophantine geometry.</p>

<p>For instance, the <em>classical</em> or <em>naive height</em> over the rational numbers is the maximum of the numerators and denominators of the coordinates. For example, the height of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mn>3</mn><mi mathvariant="normal">/</mi><mn>9</mn><mo separator="true">,</mo><mn>1</mn><mi mathvariant="normal">/</mi><mn>2</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(3/9, 1/2)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">3/9</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">1/2</span><span class="mclose">)</span></span></span></span> is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn></mrow><annotation encoding="application/x-tex">3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span>.</p>

<p>For interested readers, <a href="https://www.cambridge.org/core/books/heights-in-diophantine-geometry/4117673141D14050628601C428E8748D#fndtn-information"><em>Heights in Diophantine Geometry</em></a> by Enrico Bombieri is really helpful.</p>

<h2 id="what-have-i-done">What have I done?</h2>

<p>I contributed to 8 tickets in four different components (algebra, algebraic geometry, dynamics, and number theory). Each ticket represents a separate task and contains the implementation, tests, and documentation:</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/28263">#28263: Degree for Affine Morphism or Affine Dynamical System</a></li>
</ul>

<p>I fixed a bug in the <code class="language-plaintext highlighter-rouge">degree</code> function in <code class="language-plaintext highlighter-rouge">affine_morphism.py</code> to get me started. This function returns the degree of the affine morphism. It now not only supports polynomial affine maps, but also rational ones as well.</p>

<p>A morphism from an affine scheme to an affine scheme is determined by rational functions that define what the morphism does on points in the ambient affine space.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/33971">#33971: Height of a dynamical system is wrong</a></li>
</ul>

<p>In the past, the height of a dynamical system was incorrectly implemented as the maximum of the heights of the coefficients. It means that the code below would return <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>25</mn></mrow><annotation encoding="application/x-tex">25</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">25</span></span></span></span>, which is wrong.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sage: P.&lt;x,y&gt; = ProjectiveSpace(QQ, 1)
sage: f = DynamicalSystem([1/25*x^2 + 25/3*x*y + y^2, 1*y^2])
sage: exp(f.global_height())
</code></pre></div></div>

<p>Now we resort to the approach of treating the coefficients of all coordinate functions as a projective point, and take its height, which would give the correct answer <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>625</mn></mrow><annotation encoding="application/x-tex">625</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">625</span></span></span></span>.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/33972">#33972: Another error in height_difference_bound</a></li>
</ul>

<p>Similarly to previous ticket, the height of a polynomial typically is not the maximum of the heights of the coefficients:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>h = max([c.global_height(prec) for g in CoeffPolys for c in (g).coefficients()])
</code></pre></div></div>

<p>We again think of the height of the polynomial as a projective point (i.e., the height is independent of scaling).</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>h = max([g.global_height(prec) for g in CoeffPolys])
</code></pre></div></div>

<p>It means that for the following example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sage: P.&lt;x,y,z&gt; = ProjectiveSpace(ZZ, 2)
sage: f = DynamicalSystem_projective([4*x^2 + 100*y^2, 210*x*y, 10000*z^2])
</code></pre></div></div>

<p>In the past it returned the incorrect value <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>11.4075649493124</mn></mrow><annotation encoding="application/x-tex">11.4075649493124</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">11.4075649493124</span></span></span></span>, and now it would output the correct value <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>10.3089526606443</mn></mrow><annotation encoding="application/x-tex">10.3089526606443</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">10.3089526606443</span></span></span></span>.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/34060">#34060: Height function for polynomials on number fields</a></li>
</ul>

<p>We added the support for height functions for polynomial on number fields, which means that, for instance, the following example is now valid:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sage: R.&lt;x,y&gt; = PolynomialRing(QQbar, 2)
sage: f = QQbar(i)*x^2 + 3*x*y
sage: f.global_height()
1.09861228866811
</code></pre></div></div>

<p>Other than <code class="language-plaintext highlighter-rouge">global_height</code>, I also implemented <code class="language-plaintext highlighter-rouge">local_height</code> and <code class="language-plaintext highlighter-rouge">local_height_arch</code>.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/34175">#34175: <code class="language-plaintext highlighter-rouge">global_height</code> for polynomials fails when passed the zero polynomial</a></li>
</ul>

<p>The <code class="language-plaintext highlighter-rouge">global_height</code> for polynomials would fail when passed the zero
polynomial, since <code class="language-plaintext highlighter-rouge">number_of_terms</code> would return <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>, and then it would create a projective space of dimension <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">-1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">−</span><span class="mord">1</span></span></span></span>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sage: R.&lt;x&gt; = QQ[]
sage: f = 0 * x
sage: f.global_height()
</code></pre></div></div>

<p>Which meant that the above code would err. It now would correctly return <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/34212">#34212: <code class="language-plaintext highlighter-rouge">log_embedding</code> for number field elements</a></li>
</ul>

<p>I implemented <code class="language-plaintext highlighter-rouge">logarithmic_embedding</code> for number fields and relative number fields. Interested readers may see Definition 4.9.6 in <em>A Course in Computational Algebraic Number Theory</em> written by Henri Cohen.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/32686">#32686: points_of_bounded_height for projective space is incorrect</a></li>
</ul>

<p>Before this ticket, the <code class="language-plaintext highlighter-rouge">points_of_bounded_height</code> function for projective spaces would return points that are larger than the specified bound:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>B = 3
K.&lt;v&gt; = QuadraticField(3)
P.&lt;x,y,z&gt; = ProjectiveSpace(K,2)
for Q in P.points_of_bounded_height(bound=B):
    if exp(Q.global_height()) &gt; B + 0.001:
        print(Q,exp(Q.global_height()))
</code></pre></div></div>

<p>If you run the above code, it would return a lot of unnecessary points whose heights are larger than <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn></mrow><annotation encoding="application/x-tex">3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span>.</p>

<p>With the help of Dr. David Krumm’s <a href="https://doi.org/10.1090/mcom/2984">paper</a> and code, we successfully resolved this issue.</p>

<ul>
  <li><a href="https://trac.sagemath.org/ticket/21129">#21129: Arakelov-Zhang pairing of rational maps</a></li>
</ul>

<p>Prof. Fili wrote the original documentation and function definition many years ago. Some of the functions used and coding conventions might be slightly outdated, so I help to update it.</p>

<h2 id="what-happens-after-the-coding-period">What happens after the coding period?</h2>

<p>After the official coding period, I hope to continue to contribute to open-source software and SageMath. I will implement the height functions for projective subvarieties as well.</p>]]></content><author><name>Jing Guo</name><email>dev.guoj@gmail.com</email></author><summary type="html"><![CDATA[Summary of Google Summer of Code 2022 contributions to SageMath: height functions, logarithmic embeddings, points of bounded height, and Arakelov-Zhang pairing.]]></summary></entry></feed>