Opened 19 months ago
Closed 18 months ago
#24199 closed enhancement (wontfix)
Simplifications in calculus on manifolds with derivatives of symbolic functions
Reported by: | egourgoulhon | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | geometry | Keywords: | manifold calculus |
Cc: | mmancini, rllozes, tscrim | Merged in: | |
Authors: | Eric Gourgoulhon | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | public/manifolds/better_simplifications-24199 (Commits) | Commit: | 6eb6bdefa0cae2a02e421f2e62713d22643e01ba |
Dependencies: | Stopgaps: |
Description
The function sage.manifolds.utilities.simplify_sqrt_real
, which is involved in calculus on manifolds (see here), does not simplify sqrt's as soon as the expression contains some derivative of a symbolic function:
sage: from sage.manifolds.utilities import simplify_sqrt_real sage: f = function('f') sage: assume(x<1) sage: simplify_sqrt_real(sqrt(x^2-2*x+1)) # OK -x + 1 sage: simplify_sqrt_real(sqrt(x^2-2*x+1) * diff(f(x), x)) # nothing done sqrt(x^2 - 2*x + 1)*diff(f(x), x)
The same limitation holds for derivatives denoted by D[...]
instead of diff
:
sage: y = var('y'); s = sqrt(x^2-2*x+1) * diff(f(x), x).subs(x=y^2); s sqrt(x^2 - 2*x + 1)*D[0](f)(y^2) sage: simplify_sqrt_real(s) # nothing done sqrt(x^2 - 2*x + 1)*D[0](f)(y^2)
Similarly, the function sage.manifolds.utilities.simplify_abs_trig
does not perform any simplification when a derivative is present:
sage: from sage.manifolds.utilities import simplify_abs_trig sage: assume(x>0); assumptions() [x < 1, x > 0] sage: simplify_abs_trig(abs(sin(x))) # OK sin(x) sage: simplify_abs_trig(abs(sin(x)) * diff(f(x), x)) # nothing done abs(sin(x))*diff(f(x), x)
The code introduced in this ticket repairs this. We have now, with the same assumptions as above:
sage: simplify_sqrt_real(sqrt(x^2-2*x+1) * diff(f(x), x)) -(x - 1)*diff(f(x), x) sage: simplify_sqrt_real(s) -(x - 1)*D[0](f)(y^2) sage: simplify_abs_trig(abs(sin(x)) * diff(f(x), x)) sin(x)*diff(f(x), x)
In addition, simplify_abs_trig
is now capable to treat abs(cos(...))
:
sage: simplify_abs_trig(abs(cos(x))) # recall that 0 < x < 1 < pi/2 cos(x) sage: simplify_abs_trig(abs(cos(x+2))) -cos(x + 2) sage: simplify_abs_trig(abs(cos(x+2)) * diff(f(x), x)) -cos(x + 2)*diff(f(x), x)
Change History (7)
comment:1 Changed 19 months ago by
- Branch set to public/manifolds/better_simplifications-24199
- Cc mmancini rllozes tscrim added
- Commit set to 6eb6bdefa0cae2a02e421f2e62713d22643e01ba
- Status changed from new to needs_review
comment:2 follow-up: ↓ 4 Changed 19 months ago by
LGTM.
As a possible improvement for another ticket, instead of string manipulations, you might want to consider contacting, e.g., Ralf (rws) to see if there is a better way by directly manipulating the expression tree. Or if there is an easy way to fix some of these problems upstream.
comment:3 Changed 19 months ago by
- Reviewers set to Travis Scrimshaw
- Status changed from needs_review to positive_review
comment:4 in reply to: ↑ 2 ; follow-up: ↓ 5 Changed 19 months ago by
Replying to tscrim:
As a possible improvement for another ticket, instead of string manipulations, you might want to consider contacting, e.g., Ralf (rws) to see if there is a better way by directly manipulating the expression tree. Or if there is an easy way to fix some of these problems upstream.
Thanks for the suggestion. I agree that using the expression tree would be an improvement.
And thank you for the review!
comment:5 in reply to: ↑ 4 Changed 19 months ago by
Replying to egourgoulhon:
Replying to tscrim:
As a possible improvement for another ticket, instead of string manipulations, you might want to consider contacting, e.g., Ralf (rws) to see if there is a better way by directly manipulating the expression tree. Or if there is an easy way to fix some of these problems upstream.
Thanks for the suggestion. I agree that using the expression tree would be an improvement.
Done in #24232
comment:6 Changed 19 months ago by
- Milestone changed from sage-8.1 to sage-duplicate/invalid/wontfix
This is superseded by #24232.
comment:7 Changed 18 months ago by
- Resolution set to wontfix
- Status changed from positive_review to closed
New commits:
Improve simplifications in calculus on manifolds when derivatives of symbolic functions are involved