Skip to content

Commit 5d51afc

Browse files
authored
fix Jacobian culculation of ikeda map (#37)
1 parent f74ea57 commit 5d51afc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/discrete_famous_systems.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,20 +509,26 @@ function ikedamap(u0=[1.0, 1.0]; a=1.0, b=1.0, c=0.4, d =6.0)
509509
return DeterministicIteratedMap(ikedamap_rule, u0, [a,b,c,d])
510510
end
511511
@inbounds function ikedamap_rule(u, p, n)
512-
a,b,c,d = p
512+
a, b, c, d = p
513513
t = c - d/(1 + u[1]^2 + u[2]^2)
514514
dx = a + b*(u[1]*cos(t) - u[2]*sin(t))
515515
dy = b*( u[1]*sin(t) + u[2]*cos(t) )
516516
return SVector{2}(dx, dy)
517517
end
518518
@inbounds function ikedamap_jacob(u, p, n)
519-
#Checked the calculation of the jacobian with the calculations here https://www.math.arizona.edu/~ura-reports/001/huang.pojen/2000_Report.html. It has a wrong sign in the model definition, but the Jacobian fits.
520-
a,b,c,d = p
521-
x,y = u
522-
t = c - d/(1 + x^2 + y^2)
523-
aux = 2*d/(1+x^2+y^2)
524-
return SMatrix{2,2}(b*(cos(t)-x^2*sin(t)*aux -x*y*cos(t)*aux), b*(sin(t) +x^2*cos(t)*aux)-x*y*sin(t)*aux,
525-
b*(-sin(t) -x*y*sin(t)*aux -y^2*cos(t)*aux), b*(cos(t) -x*y*cos(t)*aux -y^2*sin(t)*aux))
519+
a, b, c, d = p
520+
x, y = u
521+
t = c - d/(1 + x^2 + y^2)
522+
s, cc = sin(t), cos(t)
523+
r2 = 1 + x^2 + y^2
524+
aux = 2d/(r2^2)
525+
526+
J11 = b*( cc - aux*( x^2*s + x*y*cc) )
527+
J12 = b*( -s - aux*( x*y*s + y^2*cc) )
528+
J21 = b*( s + aux*( x^2*cc - x*y*s) )
529+
J22 = b*( cc + aux*( x*y*cc - y^2*s) )
530+
531+
return @SMatrix [J11 J12; J21 J22]
526532
end
527533

528534

0 commit comments

Comments
 (0)