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

Returns valid result for functions like sin(f(x)) #15516

Closed
wants to merge 5 commits into from

Conversation

m-agboola
Copy link

@m-agboola m-agboola commented Nov 20, 2018

Returns valid result for functions like sin(f(x))
(all as suggested by @normalhuman)

Fixes issue #15511

Earlier,

In [12]: A = sin(x**2 + 2*x) In [13]: A.taylor_term(4, x) Out[13]: 0

Now
In [12]: A = sin(x**2 + 2*x) In [13]: A.taylor_term(4, x) Out[13]: -2x**4

Release Notes

  • functions
    • fixed a bug in taylor_term

@sympy-bot
Copy link

sympy-bot commented Nov 20, 2018

Hi, I am the SymPy bot (v134). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.4.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

Returns valid result for functions like sin(f(x))
(all as suggested by @normalhuman)


Fixes issue #15511 

Earlier,

`In [12]: A = sin(x**2 + 2*x)
In [13]: A.taylor_term(4, x)
Out[13]: 0`

Now
`In [12]: A = sin(x**2 + 2*x)
In [13]: A.taylor_term(4, x)
Out[13]: -2x**4`

#### Release Notes

<!-- BEGIN RELEASE NOTES -->
* functions
  * fixed a bug in taylor_term
<!-- END RELEASE NOTES -->

def taylor_term(n, x, *previous_terms):
def taylor_term(self, n, x, *previous_terms):
if self.args[0] != x:
return super(sin, self).taylor_term(n, x, *previous_terms)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in Airy function class. Why super(sin, self)? And why the change in Airy but not any other functions?

Copy link
Author

@m-agboola m-agboola Nov 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! That was a silly of me, I thought I changed the Sin class

@@ -1124,9 +1124,11 @@ def fdiff(self, argindex=1):
else:
raise ArgumentIndexError(self, argindex)

@staticmethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear why talor_term is a staticmethod, but does this break the API?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmeurer being a staticmethod implies sin(2*x).taylor_term(1, x) and sin(x).taylor_term(1, x) will return the same thing, which doesn't seem right. Of course, removing the decorator is not the only thing to do here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't understand why it is done that way, but I noticed that all the other taylor_term methods in SymPy are staticmethods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place I found in the code where taylor_term is called on a class, and it can just be replaced with self.taylor_term:

g = log.taylor_term(i, p, g)

I think we can most likely remove the static method. If someone needs to generate the taylor term for specific class they can create an instance with a dummy variable. It's a (minor) backwards compatibility break so if we do refactor this we should be sure to mention it in the relevant section of the release notes.

@m-agboola
Copy link
Author

m-agboola commented Nov 28, 2018

I just made some changes. Please check it out.

@RituRajSingh878
Copy link
Contributor

@m-agboola Are you still working on this because i want to work on this issue.

@m-agboola
Copy link
Author

Yes @RituRajSingh878. I'm updating my pull request very soon

@oscarbenjamin
Copy link
Collaborator

Are you still working on this?

@oscarbenjamin oscarbenjamin added the PR: author's turn The PR has been reviewed and the author needs to submit more changes. label Jan 28, 2019
@czgdp1807
Copy link
Member

@m-agboola Are you still working on is? Please resolve the conflicts.


cdef double z = 0
test(x, y, &z)
return z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline here.

@czgdp1807
Copy link
Member

I think you have deleted, sympy/functions/elementary/exponential.py by mistake. Please add the file again.

@czgdp1807
Copy link
Member

Closing this in favour of #15603

@czgdp1807 czgdp1807 closed this Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions PR: author's turn The PR has been reviewed and the author needs to submit more changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants