Skip to content

refactor(Analysis): golf Mathlib/Analysis/Complex/Trigonometric#38274

Open
yuanyi-350 wants to merge 1 commit intoleanprover-community:masterfrom
yuanyi-350:A_3
Open

refactor(Analysis): golf Mathlib/Analysis/Complex/Trigonometric#38274
yuanyi-350 wants to merge 1 commit intoleanprover-community:masterfrom
yuanyi-350:A_3

Conversation

@yuanyi-350
Copy link
Copy Markdown
Collaborator

  • rewrites cos_three_mul via cosh_three_mul and the cosh_mul_I conversion
  • shortens sin_three_mul using sin_add, double-angle identities, and grind

Extracted from #37968

Open in Gitpod

@yuanyi-350 yuanyi-350 added codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly labels Apr 20, 2026
@github-actions
Copy link
Copy Markdown

PR summary c3e588b468

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions bot added the t-analysis Analysis (normed *, calculus) label Apr 20, 2026
@yuanyi-350
Copy link
Copy Markdown
Collaborator Author

I ran a profiler comparison for the changed declarations in this PR.

Results (seconds):

  • Complex.cos_three_mul: 0.061700 -> 0.006364 (-89.7%)
  • Complex.sin_three_mul: 0.046297 -> 0.131374 (+183.8%)

Overall:

  • Complex.cos_three_mul is much faster.
  • Complex.sin_three_mul is slower, mainly from the new grind step.

rw [h2, cos_sq']
ring
rw [← two_add_one_eq_three, add_one_mul, sin_add (2 * x) x]
grind [cos_two_mul, sin_two_mul, cos_sq']
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the performance is worse, maybe do this instead:

Suggested change
grind [cos_two_mul, sin_two_mul, cos_sq']
simp only [cos_two_mul, sin_two_mul, cos_sq', mul_assoc, ← sq]
ring

same proof as before, but without the haves. Should probably have the same performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex OpenAI Codex wrote (parts of) this PR. LLM-generated PRs with substantial input from LLMs - review accordingly t-analysis Analysis (normed *, calculus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants