Closed lbenet closed 4 years ago
The problem is solved by JuliaDiff/TaylorSeries.jl#236; we will require a new tag of TaylorSeries.jl and related updates here.
Very nice! Strange that this didn't pop up earlier.
Incidentally, is there any technical difference between using u[1]-0.01*u[1]^3
or u[1]-(0.01*(u[1]*u[1])*u[1])
? (I mean, performance-wise, by using parentheses to force binary operations).
Very nice! Strange that this didn't pop up earlier.
We spotted this a week or two ago, precisely playing with the Duffing equation.
Incidentally, is there any technical difference between using u[1]-0.01u[1]^3 or u[1]-(0.01(u[1]u[1])u[1])? (I mean, performance-wise, by using parentheses to force binary operations).
Yes, there is a performance difference. The complexity of the calculation is what matters (for performance). One product of two series has "complexity 1", as well as the power. So exchanging a^3
by (a*a)*a
does have a performance penalty. I think there may e precision difference too.
Fixed by https://github.com/JuliaDiff/TaylorSeries.jl/pull/236 and #100
There is a subtle problem when using the macro in functions involving
^r
(forr
different from 0, 1, 2). I illustrate the problem here with the integration of the Duffing equation, using of the macro (using current master ofTaylorSeries
):The problem is related with
TaylorSeries.pow!
and the fact that it requires one parameter (the order of the first non-zero entry of a polynomial), which by default is set to zero. That default is used by@taylorize
, which produces theNaN
s in this case, and it does not appear if one computesc = a^3
.The problem is solved by https://github.com/JuliaDiff/TaylorSeries.jl/pull/236; we will require a new tag of
TaylorSeries.jl
and related updates here.