Skip to content

A lambda is applied to its argument before its body is simplified - #2156

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-lambda-is-applied-before-its-body-is-simplified
Oct 27, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-lambda-is-applied-before-its-body-is-simplified

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #2132.

A wrong answer: applying a lambda to a vector gave a matrix of vectors.

Input Was (2.6.0) Now
apply(lambda(u, [[0, -1], [1, 0]] * u), [p, q]) [[0, [-p, -q]], [[p, q], 0]] [-q, p]
apply(lambda(u, [1, 1]T * u), [p, q]) [[[p, q], [p, q]]] p + q

Cause. Application.InnerSimplify simplified the lambda first and then put the argument into what came back. A simplified body treats its parameter as a number, as every symbol is one, so [[0, -1], [1, 0]] * u had already become [[0, -u], [u, 0]] by the time [p, q] went in.

Fix. A lambda written in place is applied to its argument first, and the result is then simplified. A lambda that only appears once the function part is simplified is applied as before.

Checked:

apply(lambda(x, x * x), [1, 2]) still simplifies to [1, 4] on this branch. That is #2141's elementwise power, which #2155 fixes.

Found while reading Modenov's Problems in Geometry for #2131, whose rotation of a plane vector through π/2 is this lambda.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Simplifying an application simplified the lambda first and put the
argument into what came back. A simplified body treats its parameter as
a number, as every symbol is one, so [[0, -1], [1, 0]] * u became
[[0, -u], [u, 0]], and the vector [p, q] put in for u gave the matrix of
vectors [[0, [-p, -q]], [[p, q], 0]] where the product is [-q, p]. A
dot product written [1, 1]T * u gave [[[p, q], [p, q]]] for p + q.

A lambda written in place is now applied to its argument first, and the
result simplified. A lambda that only appears once its function part is
simplified is applied as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 27, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 27, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit b3b6cd2 into master Oct 27, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 27, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-lambda-is-applied-before-its-body-is-simplified branch October 27, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Applying a lambda to a vector treats the vector as a number

1 participant