-
Notifications
You must be signed in to change notification settings - Fork 53
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
Include offset in struct definition #313
Comments
Hi @KeithWM, thanks for the opening this issue! Let me begin with a "yes", if you think the package can be improved in some way please do open issues and PRs!
I agree partially with what you write, so let me rewrite it in my terms. Yes, the object If I understand correctly your idea/proposal with This type of idea, perhaps in a less elegantly way, is implemented/exploited in TaylorModels.jl. The subtlety there is, because Finally, I'm not sure if a new type would be needed, or simply add |
Hi there. Thanks for the swift and extensive answer. I've now implemented in my own package rather compactly by using the fact that a It's probably quite sensible to add |
I see your point. Aside from the discussion of having julia> x = Taylor1(5) # independent variable "around 0"; at t=0 --> x = 0
1.0 t + 𝒪(t⁶)
julia> x0 = 0.25
0.25
julia> z = x0 + x # indep variable around x0 (at t=0 --> z = x0)
0.25 + 1.0 t + 𝒪(t⁶)
julia> y = sin(z) # TS around x0 for `sin`
0.24740395925452294 + 0.9689124217106447 t - 0.12370197962726147 t² - 0.1614854036184408 t³ + 0.010308498302271788 t⁴ + 0.00807427018092204 t⁵ + 𝒪(t⁶)
# Your `y(z)` above corresponds to `y` here, I believe
julia> y(-x0+x) # translation of TS to be around 0
7.207371574557975e-8 + 0.9999983177913969 t + 1.615523415198633e-5 t² - 0.16674748305763631 t³ + 0.00021566057611923858 t⁴ + 0.00807427018092204 t⁵ + 𝒪(t⁶)
# "exact" result
julia> sin(x)
1.0 t - 0.16666666666666666 t³ + 0.008333333333333333 t⁵ + 𝒪(t⁶)
# the *same* translation using `update!` on a copy of `y`
julia> yy = y;
julia> update!(yy, -x0);
julia> yy
- 0.2474001108545715 + 0.9688693089044778 t + 0.12389603552765488 t² - 0.16191672477067928 t³ - 0.00987717715003331 t⁴ + 0.00807427018092204 t⁵ + 𝒪(t⁶) Three comments:
|
I'm not entirely sure we're on the same page about the offsets, but maybe I'm misunderstanding the notation. Instead of This does indeed create a polynomial expansion about |
I agree with you that there is an issue with the notation... Let us then expand julia> x0 = 1.0
1.0
julia> hT = Taylor1(5) # small quantity
1.0 t + 𝒪(t⁶)
julia> x = x0 + hT
1.0 + 1.0 t + 𝒪(t⁶)
julia> Y = log(x)
1.0 t - 0.5 t² + 0.3333333333333333 t³ - 0.25 t⁴ + 0.2 t⁵ + 𝒪(t⁶) Note that there is an overall multiplicative -1 with respect to what you wrote as julia> Y(0.01)
0.009950330853333333
julia> log(1.01)
0.009950330853168092 Not the same, but a good approximation. So indeed evaluating Let us obtain (an approximation of) the Taylor expansion of julia> z0 = 1.25
1.25
julia> Y(z0+hT-x0) # Same result, updating the definition of Y, as `update!(Y, z0-x0)`
0.22317708333333333 + 0.80078125 t - 0.3125 t² + 0.20833333333333331 t³ - 1.3877787807814457e-17 t⁴ + 0.2 t⁵ + 𝒪(t⁶)
julia> log(z0+hT) # for comparison
0.22314355131420976 + 0.8 t - 0.32 t² + 0.1706666666666667 t³ - 0.1024 t⁴ + 0.06553600000000001 t⁵ + 𝒪(t⁶) In these expressions |
Hi all, thanks for the great repository!
I've been working on a package to compute the Taylor expansion of the inverse of a function
y=f(x)
based on the Taylor expansion off
as described by Wolfram I might want to add this here. But that's not my point here.To me it seems that given a Taylor series expansion is an approximation to a function
f(x)
around some pointx_0
, to evaluate the approximation you ideally want to call theTaylor1
object with just the argumentx
, without having to think about/remember whatx_0
was used in defining the expansion.It might be an idea to implement an
OffsetTaylor{N}
object that houses aTaylor{N}
object along with the used offsets? Curious what you guys think about this. Happy to help implementing things too!The text was updated successfully, but these errors were encountered: