Skip to content

Commit

Permalink
Fix bound_truncation for TaylorModel1 with TaylorN{T} coeffs (#136)
Browse files Browse the repository at this point in the history
* Add method of bound_truncation for TaylorModel1 involving TaylorN{T} coeffs

* Add tests

* Bump patch version
  • Loading branch information
lbenet committed Mar 4, 2022
1 parent cd837f3 commit 0195c68
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "TaylorModels"
uuid = "314ce334-5f6e-57ae-acf6-00b6e903104a"
repo = "https://github.com/JuliaIntervals/TaylorModels.jl.git"
version = "0.5.3"
version = "0.5.4"

[deps]
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
Expand Down
11 changes: 11 additions & 0 deletions src/auxiliary.jl
Expand Up @@ -77,6 +77,17 @@ for TM in tupleTMs
end
end

function bound_truncation(::Type{TaylorModel1}, a::Taylor1{TaylorN{T}}, aux::Interval,
order::Int) where {T}
order get_order(a) && return zero(aux)
# Assumes that the domain for the TaylorN variables is the symmetric normalized box -1 .. 1
symIbox = IntervalBox(-1 .. 1, get_numvars())
res = Taylor1(evaluate.(a.coeffs, Ref(symIbox)))
res[0:order] .= zero(res[0])
return res(aux)
end


function fixorder(a::TaylorModelN, b::TaylorModelN)
@assert tmdata(a) == tmdata(b)
a.pol.order == b.pol.order && return a, b
Expand Down
22 changes: 22 additions & 0 deletions test/TM1.jl
Expand Up @@ -197,6 +197,28 @@ end
t = Taylor1([qaux,1], orderT)
tm = TaylorModel1(deepcopy(t), -0.25 .. 0.25, x00, dom)
@test integrate(tm, symIbox) == TaylorModel1(integrate(t), remainder(tm)*(domain(tm)-expansion_point(tm)), x00, dom)

# Changing order of a TM1 with TaylorN coeffs
t = Taylor1([qaux, 1], orderT)
tm = TaylorModel1(deepcopy(t), 0 .. 0, x00, dom) # order 4
t8 = Taylor1([qaux, 1], 2*orderT)
tm8 = TaylorModel1(deepcopy(t8), 0 .. 0, x00, dom)
tm4, _ = TaylorSeries.fixorder(tm8, tm)
@test get_order(tm4) == get_order(tm)
@test polynomial(tm4) == polynomial(tm)
#
exp_tm = exp(tm)
exp_tm8 = exp(tm8)
exp_tm4, _ = TaylorSeries.fixorder(exp_tm8, tm)
@test get_order(exp_tm4) == get_order(exp_tm)
@test polynomial(exp_tm4) == polynomial(exp_tm)
for ind = 1:_num_tests
= rand(dom)-x00
= rand(symIbox)
tt = t(xξ)(qξ)
@test exp(tt) exp_tm4(dom-x00)(symIbox)
@test exp(tt) exp_tm(dom-x00)(symIbox)
end
end

@testset "RPAs, functions and remainders" begin
Expand Down

2 comments on commit 0195c68

@lbenet
Copy link
Member Author

@lbenet lbenet commented on 0195c68 Mar 4, 2022

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/56000

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.4 -m "<description of version>" 0195c684d72e6248cc14f56bf94f528a3fbdb8b3
git push origin v0.5.4

Please sign in to comment.