Skip to content

Conversation

@LuEdRaMo
Copy link
Contributor

In master, running the following block of code:

begin
    using TaylorSeries
    import Random
    Random.seed!(1234)
    inorder = 6
    outorder = 25
    x = Taylor1([Taylor1(rand(inorder+1), inorder) for _ in 1:outorder+1], outorder)
    y, z = zero(x), zero(x)
    for r in [0, 1, 2, 3, 4]
        println("x^$r")
        for k in eachindex(z)
            TS.pow!(z, x, y, r, k)
        end
        @time for k in eachindex(z)
            TS.pow!(z, x, y, r, k)
        end
        println("|z - x^$r|∞ = ", norm(z - x^r, Inf))
    end
 end

produces the following output:

x^0
  0.000005 seconds (35 allocations: 1.219 KiB)
|z - x^0|∞ = 0.0
x^1
  0.000005 seconds (35 allocations: 1.219 KiB)
|z - x^1|∞ = 0.0
x^2
  0.000034 seconds (60 allocations: 3.953 KiB)
|z - x^2|∞ = 0.0
x^3
  0.000059 seconds (35 allocations: 1.219 KiB)
|z - x^3|∞ = 0.0
x^4
  0.000041 seconds (35 allocations: 1.219 KiB)
|z - x^4|∞ = 0.0

showing that squaring a nested Taylor1 allocates twice the memory. This PR proposes a quick fix.

@lbenet
Copy link
Member

lbenet commented Sep 20, 2025

Hve you checked that everything is ok in TaylorIntegration, in particular wrt the use of @taylorize?

@coveralls
Copy link

coveralls commented Sep 20, 2025

Coverage Status

coverage: 92.733% (+0.1%) from 92.609%
when pulling e8e6a7d on LuEdRaMo:lerm/pow
into fc1dcbd on JuliaDiff:master.

@LuEdRaMo
Copy link
Contributor Author

Hve you checked that everything is ok in TaylorIntegration, in particular wrt the use of @taylorize?

In my computer, all TaylorIntegration tests pass except for those related to the DiffEq extension, which I reckon is not related to this PR.

@lbenet
Copy link
Member

lbenet commented Sep 20, 2025

I've also noticed that on my computer; I think it is due to some recent upgrade in DiffEq, that I haven't yet traced back

@lbenet
Copy link
Member

lbenet commented Sep 20, 2025

Incidentally, when you bump the patch version related to this PR, can you also include compatibility with IA v0.23 (so it works with 0.23 and 1 as well)? See this for some context.

@LuEdRaMo
Copy link
Contributor Author

Incidentally, when you bump the patch version related to this PR, can you also include compatibility with IA v0.23 (so it works with 0.23 and 1 as well)? See this for some context.

Done.

If you have no further comments, I think this PR is ready...

@lbenet
Copy link
Member

lbenet commented Sep 20, 2025

Thanks a lot for this improvement!

@lbenet lbenet merged commit 86933d7 into JuliaDiff:master Sep 20, 2025
13 checks passed
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.

3 participants