Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctest fix: f.subs(I==...) does not work #23964

Open
zimmermann6 opened this issue Oct 4, 2017 · 12 comments
Open

Doctest fix: f.subs(I==...) does not work #23964

zimmermann6 opened this issue Oct 4, 2017 · 12 comments

Comments

@zimmermann6
Copy link

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)

Depends on #24838

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/23964

@zimmermann6 zimmermann6 added this to the sage-8.1 milestone Oct 4, 2017
@rwst
Copy link

rwst commented Oct 4, 2017

comment:1

The documentation: Substitute with keyword arguments (works only with symbols):. For you I is a symbol but for Pynac it's numeric. Just use dictionary or relational syntax:

sage: f = sin(x*I)+I*x^2+cos(exp(I))
sage: f
I*x^2 + cos(e^I) + I*sinh(x)
sage: f.subs({I:0})
I*x^2 + cos(1) + I*sinh(x)
sage: f.subs(I==0)
I*x^2 + cos(1) + I*sinh(x)

As you can see the I inside cos(e^I) is now replaced. I agree that the other Is not being replaced is a bug. The bug is independent of which numeric is to be substituted:

sage: f = sin(x*2)+2*x^2+cos(exp(2))
sage: f
2*x^2 + cos(e^2) + sin(2*x)
sage: f.subs({2:0})
cos(1) + sin(2*x) + 2

@zimmermann6
Copy link
Author

comment:2

thank you. Should I open a new ticket for this bug? Or simply change the ticket description?

@rwst
Copy link

rwst commented Oct 4, 2017

comment:3

Done. I think I will restrict the numerics that can be replaced (not 0 nor 1).

@rwst rwst changed the title f.subs(I=...) does not work f.subs(I==...) does not work Oct 4, 2017
@zimmermann6
Copy link
Author

comment:4

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.

@zimmermann6 zimmermann6 changed the title f.subs(I==...) does not work f.subs(I=...) does not work Oct 4, 2017
@zimmermann6 zimmermann6 changed the title f.subs(I=...) does not work f.subs(I==...) does not work Oct 4, 2017
@zimmermann6
Copy link
Author

comment:6

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.

@rwst

This comment has been minimized.

@rwst
Copy link

rwst commented Oct 4, 2017

comment:7

Yeah that was an enhancement in a recent Pynac (#23820).

@jdemeyer
Copy link

jdemeyer commented Oct 4, 2017

comment:8

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)?

@rwst
Copy link

rwst commented Oct 4, 2017

comment:9

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

@rwst
Copy link

rwst commented Mar 9, 2018

comment:10

This will be available with pynac-0.7.18 and should be doctested here.

@rwst
Copy link

rwst commented Mar 23, 2018

Dependencies: #24838

@rwst rwst changed the title f.subs(I==...) does not work Doctest fix: f.subs(I==...) does not work Mar 23, 2018
@rwst
Copy link

rwst commented Jul 1, 2018

comment:12

The original case works now, the minimal case I*x not, so there is an inconsistency to resolve.

@mkoeppe mkoeppe removed this from the sage-8.1 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants