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

Correct the returned series when factorizing, with tests #145

Merged
merged 4 commits into from
Feb 19, 2018

Conversation

lbenet
Copy link
Member

@lbenet lbenet commented Feb 16, 2018

This fixes #58 and other similar cases.

@lbenet
Copy link
Member Author

lbenet commented Feb 16, 2018

I'll add a summary here: Currently, in master, we get the following:

julia> t = Taylor1(5)
 1.0 t + 𝒪(t⁶)

julia> 1/(1+t)
 1.0 - 1.0 t + 1.0- 1.0+ 1.0 t⁴ - 1.0 t⁵ + 𝒪(t⁶)

julia> t/(t+t^2) # should be identical to the result above
 1.0 - 1.0 t + 1.0- 1.0+ 1.0 t⁴ + 𝒪(t⁶)

julia> t*sqrt(1+t)
 1.0 t + 0.5- 0.125+ 0.0625 t⁴ - 0.0390625 t⁵ + 𝒪(t⁶)

julia> sqrt(t^2+t^3) # should be identical to the result above
 1.0 t + 0.5- 0.125+ 𝒪(t⁶)

This PR corrects this.

@lbenet
Copy link
Member Author

lbenet commented Feb 16, 2018

Tests should pass now...

@coveralls
Copy link

coveralls commented Feb 16, 2018

Coverage Status

Coverage increased (+0.01%) to 97.185% when pulling f9d1f0f on lb/truncation into 34f7a48 on master.

@lbenet
Copy link
Member Author

lbenet commented Feb 16, 2018

@dpsanders I think this is ready!

@dpsanders
Copy link
Contributor

I don't follow the calculations, but if the new tests work, LGTM!

@lbenet
Copy link
Member Author

lbenet commented Feb 19, 2018

The basic idea is to mimic an "extension" of the order of the independent variable, by using zeros appropriately; this is used to compute the coefficients (which before were simply set to zero) to the correct order.

Considering the example of sqrt(t^2+t^3) with t=Taylor1(5), the idea is to treat the independent variable of the expression as being of order 7 (instead of order 5), because t^2 can be factorized (which are the two orders lost in the returned expression). So the idea is to mimic the behavior of sqrt( Taylor1(7)^2+Taylor1(7)^3 ) (using t and zeros for order 6 and 7) and return the result up to order 5.

I hope this short explanation makes some sense.

EDIT: Corrected the markdown...

@lbenet lbenet merged commit 4a1eed0 into master Feb 19, 2018
@lbenet lbenet deleted the lb/truncation branch February 22, 2018 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqrt gives misleading O() term
3 participants