Repository navigation
A value put in for a derivative's variable is where it is evaluated - #2199
Merged
Rafael-SOWNet merged 3 commits intoOct 29, 2026
Merged
Rafael-SOWNet merged 3 commits into
Rafael-SOWNet merged 3 commits into
Conversation
Substitute treated the variable of a derivative and of an indefinite integral as bound, and a value put in for it was dropped: derivative(x^3, x) at x = 1 evaluated to 3 x^2, and integral(x^2, x) at x = 1 to x^3/3 + C. That variable is free, the derivative being a function of it, as FreeVariables already counted it since #1045. Substituting and evaluating did not commute. A value for it now makes apply(lambda(x, derivative(f, x)), v), the derivative evaluated at v, in syntax the library already has, so Substitute still computes nothing. Applying a lambda whose body is a derivative or an indefinite integral in its parameter takes that body first and then puts the argument in. Every other body is substituted before it is simplified, as #2132 needs. That order had made apply(lambda(x, derivative(x^3, x)), 1) 3 x^2 as well, where 2.6.0 gave 3. A derivative the library does not take, such as that of primepi(x), keeps the application unevaluated rather than being taken again. A value that holds the variable, a := x in derivative(a x^2, x), was put in under a renamed variable that was then left free: derivative(x x_1^2, x_1), which is 2 x_1 x. It now goes in under a fresh variable at which the derivative is evaluated, and comes to 2 x^2, the derivative 2 a x with a put in. A definite integral, a sum, a product and a limit bind their variable, and are unchanged. Two rows of SubstituteTest pinned the dropped value, x * derivative(x + 2, x) at x = 1 as 1 * derivative(x + 2, x); they now read 1 * apply(lambda(x, derivative(x + 2, x)), 1). Fixes #2189. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2199 +/- ##
==========================================
- Coverage 86.55% 86.55% -0.01%
==========================================
Files 298 298
Lines 66529 66554 +25
Branches 19300 19308 +8
==========================================
+ Hits 57582 57603 +21
- Misses 4872 4876 +4
Partials 4075 4075
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
A variable the body does not hold is a renaming, and renames the derivative's variable: derivative(x^3, x) with x := y is derivative(y^3, y). That is what a lambda renaming its parameter puts in, and wrapped in a lambda over the old name instead it would be renamed again without end. Part of #2189. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…luated-at-the-value-put-in-for-its-variable # Conflicts: # Sources/.editorconfig
Rafael-SOWNet
deleted the
a-derivative-is-evaluated-at-the-value-put-in-for-its-variable
branch
October 29, 2026 12:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2189. A value put in for the variable of a derivative or an indefinite integral was dropped. That variable is free, since the derivative is a function of it, so substituting and then evaluating gave a different answer from evaluating and then substituting.
"derivative(x^3, x)".ToEntity().Substitute("x", 1).Evaled3 * x ^ 23"integral(x^2, x)".ToEntity().Substitute("x", 1).Evaledx ^ 3 / 3 + C1/3 + C"derivative(a x^2, x)".ToEntity().Substitute("a", "x").Evaled2 * x_1 * x2 * x * x"derivative(x^3, x)".ToEntity().Substitute("x", 1)derivative(x ^ 3, x)apply(lambda(x, derivative(x ^ 3, x)), 1)What changes:
Substitutewrites a value for that variable asapply(lambda(x, …), v), the derivative evaluated atv. It still computes nothing.derivative(x^3, x)withx := yisderivative(y^3, y). A lambda renaming its own parameter substitutes exactly such a variable, so wrapping it in anotherapplywould never terminate.Applicationtakes a derivative or indefinite integral in the lambda's parameter before putting the argument in. Every other body is still substituted first, as Applying a lambda to a vector treats the vector as a number #2132 needs. That order had also madeapply(lambda(x, derivative(x^3, x)), 1)give3 x^2on master, where 2.6.0 gave3.primepi(x), keeps the application unevaluated.The definite integral,
sum,productandlimitbind their variable and are unchanged. Two rows ofSubstituteTestpinned the dropped value, and now read1 * apply(lambda(x, derivative(x + 2, x)), 1).🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura