Opened 17 months ago
Last modified 8 months ago
#23964 new defect
Doctest fix: f.subs(I==...) does not work
Reported by: | zimmerma | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.1 |
Component: | calculus | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #24838 | Stopgaps: |
Description (last modified by )
Minimal case:
sage: (I*x).subs(I==0) I*x
Originally:
the substitute
command does not work with I
:
sage: f = sin(x*I)+I*x^2+cos(exp(I)) sage: f.subs(I=0) I*x^2 + cos(e^I) + sin(I*x)
Change History (12)
comment:1 Changed 17 months ago by
comment:2 Changed 17 months ago by
thank you. Should I open a new ticket for this bug? Or simply change the ticket description?
comment:3 Changed 17 months ago by
- Summary changed from f.subs(I=...) does not work to f.subs(I==...) does not work
Done. I think I will restrict the numerics that can be replaced (not 0
nor 1
).
comment:4 Changed 17 months ago by
- Summary changed from f.subs(I==...) does not work to f.subs(I=...) does not work
btw it is strange that you get I*sinh(x)
since with Sage 8.0 I get sin(I*x)
, i.e., this term is unchanged.
comment:5 Changed 17 months ago by
- Summary changed from f.subs(I=...) does not work to f.subs(I==...) does not work
comment:6 Changed 17 months ago by
sorry we edited the ticket simultaneously and I discarded your edit in the title and maybe in the description. I've put the title back to ===
but I'm not sure about the description.
comment:7 Changed 17 months ago by
- Description modified (diff)
Yeah that was an enhancement in a recent Pynac (#23820).
comment:8 Changed 17 months ago by
Why should (I*x).subs(I=0)
work? This I
isn't a variable, it's a complex number. Would you expect (2*x).subs({2:3})
to give (3*x)
?
comment:9 Changed 17 months ago by
Well, subs
was always about termwise substitution. Maxima does it too:
(%i3) subst(%i=y,%i*x); (%o3) x y (%i4) subst(2=y,2*x); (%o4) x y
comment:10 Changed 12 months ago by
This will be available with pynac-0.7.18 and should be doctested here.
comment:11 Changed 11 months ago by
- Dependencies set to #24838
- Summary changed from f.subs(I==...) does not work to Doctest fix: f.subs(I==...) does not work
comment:12 Changed 8 months ago by
The original case works now, the minimal case I*x
not, so there is an inconsistency to resolve.
The documentation:
Substitute with keyword arguments (works only with symbols):
. For youI
is a symbol but for Pynac it's numeric. Just use dictionary or relational syntax:As you can see the
I
insidecos(e^I)
is now replaced. I agree that the otherI
s not being replaced is a bug. The bug is independent of which numeric is to be substituted: