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

Nasty behaviour of sqrt(x) #24

Open
dpsanders opened this issue Jul 23, 2015 · 6 comments
Open

Nasty behaviour of sqrt(x) #24

dpsanders opened this issue Jul 23, 2015 · 6 comments

Comments

@dpsanders
Copy link
Contributor

I think the following should throw an error instead.

julia> x, y = set_variables("x y", order=8)
2-element Array{TaylorSeries.TaylorN{Float64},1}:
  1.0 x + 𝒪(‖x‖⁹)
  1.0 y + 𝒪(‖x‖⁹)

julia> sqrt(x)
 Inf x - NaN y - Inf x² - NaN x y - NaN y² + Inf x³ - NaN x² y - NaN x y² - NaN y³ - Inf x⁴ - NaN x³ y - NaN x² y² - NaN x y³ - NaN y⁴ + Inf x⁵ - NaN x⁴ y - NaN x³ y² - NaN x² y³ - NaN x y⁴ - NaN y⁵ - Inf x⁶ - NaN x⁵ y - NaN x⁴ y² - NaN x³ y³ - NaN x² y⁴ - NaN x y⁵ - NaN y⁶ + Inf x⁷ - NaN x⁶ y - NaN x⁵ y² - NaN x⁴ y³ - NaN x³ y⁴ - NaN x² y⁵ - NaN x y⁶ - NaN y⁷ - Inf x⁸ - NaN x⁷ y - NaN x⁶ y² - NaN x⁵ y³ - NaN x⁴ y⁴ - NaN x³ y⁵ - NaN x² y⁶ - NaN x y⁷ - NaN y⁸ + 𝒪(‖x‖⁹)
@dpsanders
Copy link
Contributor Author

I guess when the constant term is zero.

@dpsanders
Copy link
Contributor Author

Same for log

lbenet pushed a commit that referenced this issue Aug 22, 2015
Errors are thrown using `throw` (`error` is deprecated)
lbenet added a commit that referenced this issue Aug 23, 2015
Solves issue #24 throwing an ErrorException; includes tests
@dpsanders
Copy link
Contributor Author

I now get

x, y = set_variables("x y", order=8)
julia> sqrt(x^2)
ERROR: ArgumentError("The 0-th order TaylorN coefficient must be non-zero\nin order to expand `sqrt` around 0")
 in sqrt at /Users/dsanders/.julia/v0.3/TaylorSeries/src/TaylorN.jl:615

but it works for one variable:

julia> t = taylor1_variable(10)
 1.0 t + 𝒪(t¹¹)

julia> sqrt(t^2)
 1.0 t + 𝒪(t¹¹)

@lbenet
Copy link
Member

lbenet commented Aug 23, 2015

Yes, you are right; this is something known.

In simple terms, Taylor1 objects are simpler to handle and we know the way to factorize them, or to recognize that sqrt(t^2) is t. The situation is different for TaylorN objects (under the current representation we are using!). I haven't had time to think about this, but indeed this is something to be solved.

This problem does not appear if we construct TaylorN objects as Taylor1 objects, whose coefficients are polynomials in other variables. This is part of the idea in branch "TaylorRec"; see #12.

@lbenet
Copy link
Member

lbenet commented Aug 23, 2015

In my opinion, this issue should be closed, but an issue reminding us about this should definitely be open.

@lbenet
Copy link
Member

lbenet commented Aug 24, 2015

See also discussion in #11

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

No branches or pull requests

2 participants