Macaulay2 / Macaulay2/M2

A superscript on a tall base is drawn at the base's baseline instead of above it

Open Beginner friendly
#4,573 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bugs directory Core
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

This issue was triaged from [`bugs/dan/1-exponent-formatting`](https://github.com/Macaulay2/M2/blob/388c1ff0ce30d83751dea7bc7eac77fdc1305dd7/bugs/dan/1-exponent-formatting), one of the 857 files removed from the pre-GitHub `bugs/` tree by [`d2c8d27826`](https://github.com/Macaulay2/M2/commit/d2c8d27826) and catalogued in [#36](https://github.com/Macaulay2/M2/issues/36). **The commentary below was written by Claude (Claude Opus 5, via Claude Code)**, not by @d-torrance, whose account posted it -- please weigh it accordingly.

### The original file, verbatim

```text
-*- M2 -*-

i37 : (QQ[symbol x_2]/x_2^5)^6

/QQ [x ]\
| 2 |6 **************** put this exponent higher
o37 = |-------|
| 5 |
| x |
\ 2 /

QQ [x ]
2
o37 : --------module, free
5
x
2
```

### Where it stands today

Reproduces byte for byte, and the cause is one line.

`net Superscript` (`expressions.m2:774-779`) raises the exponent by `1 + depth n`, computed from the
**exponent's own** net — so the offset ignores how tall the base is. The parenthesized quotient ring in
the file measures `(height, depth) = (3,3)`: six lines with its baseline in the middle, so the exponent
lands on row 2 of 6, exactly where the file's arrow points.

### The fix, and why the obvious variant is wrong

Raising by `max(1 + depth n, height b)` against the **base** net puts the exponent above the top line,
which is what the file asks for, and is byte-identical to today's output for a one-line base and for a
matrix base — checked. The tempting `height b - 1` breaks the ordinary case by dropping the exponent onto
the baseline.

### Not a deliberate choice

`git log -S 'n^(1+depth n)'` returns only `647f7532b3`, "Initial revision" — so the formula has never
been revisited, rather than having been settled on.

### Related

**#3198** is about the parser's precedence for `_` and `^`, not about where a superscript is drawn.

`open` · disposition `issue` · source of truth: [`bug-triage/catalog.tsv`](https://github.com/d-torrance/M2/blob/bug-triage/bug-triage/catalog.tsv)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in expressions.m2 at net Superscript, lines 774-779, and reproduce the example from bugs/dan/1-exponent-formatting. Compare the rendered output for the tall quotient-ring base with the expected exponent position, then verify that ordinary one-line and matrix bases remain unchanged. Done means the superscript is above the tall base without changing those existing outputs.

Written by the indexing model from the issue text.

Assessment

Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.