TaylorSeries.jl
TaylorSeries.jl copied to clipboard
WIP: Nested Taylors
This is WIP for Nested Taylors, which I would like to benchmark eventually with TaylorIntegration's Jet Transport and compare it with TaylorN performance for a number of variables. Currently, all basic operations from arithmetic.jl are working correctly, and do as a natural extension of Taylor1 operations, but calculus.jl and other_functions.jl need to be handled differently.
To define N independent variables:
using TaylorSeries
num_vars, ord_ = (3,6)
@time x,y,z = set_nested_variables(num_vars,ord_) #coeffs type can also be specified as a third argument
0.000035 seconds (273 allocations: 12.703 KiB)
3-element Array{Number,1}:
1.0 t + 𝒪(t⁷) + 𝒪(t⁷) + 𝒪(t⁷)
1.0 + 𝒪(t⁷) t + 𝒪(t⁷) + 𝒪(t⁷)
1.0 + 𝒪(t⁷) + 𝒪(t⁷) t + 𝒪(t⁷)
@time X,Y,Z = set_variables("x",numvars=3)
0.000243 seconds (335 allocations: 25.219 KiB)
3-element Array{TaylorSeries.TaylorN{Float64},1}:
1.0 x₁ + 𝒪(‖x‖⁷)
1.0 x₂ + 𝒪(‖x‖⁷)
1.0 x₃ + 𝒪(‖x‖⁷)
Output is nothing near pretty for now, but one can check that basic operations work
@time 2x+3y^2-4z+5x*y-3z^3*x+10x
0.001323 seconds (47.58 k allocations: 3.110 MiB)
12.0 t + 𝒪(t⁷) + 5.0 t + 𝒪(t⁷) t + 3.0 + 𝒪(t⁷) t² + 𝒪(t⁷) + - 4.0 + 𝒪(t⁷) + 𝒪(t⁷) t + - 3.0 t + 𝒪(t⁷) + 𝒪(t⁷) t³ + 𝒪(t⁷)
@time 2X+3Y^2-4Z+5X*Y-3Z^3*X+10X
0.000120 seconds (1.04 k allocations: 85.328 KiB)
12.0 x₁ - 4.0 x₃ + 5.0 x₁ x₂ + 3.0 x₂² - 3.0 x₁ x₃³ + 𝒪(‖x‖⁷)
@time exp(y)
0.000234 seconds (9.07 k allocations: 610.672 KiB)
1.0 + 𝒪(t⁷) + 1.0 + 𝒪(t⁷) t + 0.5 + 𝒪(t⁷) t² + 0.16666666666666666 + 𝒪(t⁷) t³ +
0.041666666666666664 + 𝒪(t⁷) t⁴ + 0.008333333333333333 + 𝒪(t⁷) t⁵ +
0.0013888888888888887 + 𝒪(t⁷) t⁶ + 𝒪(t⁷) + 𝒪(t⁷)
@time exp(Y)
0.000018 seconds (108 allocations: 8.828 KiB)
1.0 + 1.0 x₂ + 0.5 x₂² + 0.16666666666666666 x₂³ + 0.041666666666666664 x₂⁴ +
0.008333333333333333 x₂⁵ + 0.0013888888888888887 x₂⁶ + 𝒪(‖x‖⁷)
Jet Transport for Nested Taylors can't be done yet as there isn't a well defined method for norm(x,p) where x is a Nested Taylor.
All feedback is more than welcomed, @lbenet @PerezHz @dpsanders . No tests were added yet.
EDIT: I forgot to reference the corresponding discussion of #123
Coverage increased (+2.4%) to 96.566% when pulling 43cb5f04f9697cf15d536c708eb84012dce675e7 on blas-ko:nested_taylor into 347fce177faf30535409fbf9c8b9d04492a6ab5b on JuliaDiff:master.
Just rebased. I'll continue with this work.
Did you rebased to current master? Some commits that are within this PR seem to me already merged...