# Incorrect bifurcation diagram bifurcationkit.jl

**URL:** <https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259>\
**Category:** Modelling & Simulations\
**Created:** [September 14, 2022, 8:04am UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259 "2022-09-14T08:04:11Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [September 15, 2022, 12:42pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/21 "2022-09-15T12:42:04Z")

</div>

I apologize for the many versions vf and parametres

```julia
function sigma(x)
    return 1.0 / ( 1.0 + exp( -10.0 * ( x - ( - 0.25 ) ) ) )
end

function HR(u, p)
    
    a, b, c, d, s, xr, r, I, vs, k1, k2, el_link = p
    x1, y1, z1, x2, y2, z2 = u
    
    du1 = y1 + b * x1 ^ 2 - a * x1 ^3 - z1 + I - k1 * ( x1 - vs ) * sigma(x2) + el_link * ( x2 - x1 )
    du2 = c - d * x1 ^2 - y1
    du3 = r * ( s * ( x1 - xr ) - z1 )
    
    du4 = y2 + b * x2 ^ 2 - a * x2 ^3 - z2 + I - k2 * ( x2 - vs ) * sigma(x1) + el_link * ( x1 - x2 )
    du5 = c - d * x2 ^2 - y2
    du6 = r * ( s * ( x2 - xr ) - z2 )
    return [du1, du2, du3,
            du4, du5, du6]
end

param = (a = 1.0, b = 3.0 , c = 1.0, d = 5.0, s = 5.0, xr = -1.6, r = 0.01, I = 4.0, vs = 2.0, k1 = -0.17, k2 = -0.17 , k = 0.0)

```

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 15, 2022, 12:53pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/22 "2022-09-15T12:53:57Z")

</div>

> [@Sergey\_Novak](#):
>
> ```julia
> opt_newton = NewtonPar(tol = 1e-16, maxIter = 100)
> 
> ```

You are asking too much here, make it

```julia
opt_newton = NewtonPar(tol = 1e-12, maxIter = 10)

```

You can easily debug these errors by going verbose like `opt_newton = NewtonPar(tol = 1e-12, maxIter = 10, verbose = true)`

Also, you cannot pass `recordFromSolution` to codim 2 (you could but you have to dispatch it on `BorderedArrays`), hence

```julia
hp_codim2 = continuation(br, 1, (@lens _.k1),
	ContinuationPar(opts_br, pMin = -0.5, pMax = 0.5,
		ds = -0.001, dsmax = 0.05) ;
	normC = norminf,
	# detection of codim 2 bifurcations with bisection
	detectCodim2Bifurcation = 2,
	# tell to start the Hopf problem using eigen elements: compute left eigenvector
	startWithEigen = true,
	# we update the Hopf problem at every continuation step
	updateMinAugEveryStep = 1,
	# compute both sides of the initial condition
	bothside = true,
	)

```

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [September 15, 2022, 2:02pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/23 "2022-09-15T14:02:19Z")

</div>

Thank you! It work and i get next result  
is it possible to additionally make sure that the bifurcation is found correctly?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/8/985e9db6116a01ac14f57d2a7de99354a3344a17.png)

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 15, 2022, 3:54pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/24 "2022-09-15T15:54:08Z")

</div>

you can do `getNormalForm(hp_codim2, 2)`

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [September 16, 2022, 12:10pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/25 "2022-09-16T12:10:15Z")

</div>

Thank you  
I get the following result, and as I understand it, it is incorrect because real numbers of eigenvalues not zero, perhaps this is due to accuracy

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/c/ec10c7e438ed078d8d3b924f932b78a79c00b053.png)

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 16, 2022, 1:29pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/26 "2022-09-16T13:29:44Z")

</div>

you are talking about G21 and G32? I did not take the real parts, see [Bautin · Bifurcation Analysis in Julia](https://bifurcationkit.github.io/BifurcationKitDocs.jl/dev/bautin/).

For codim 1,2 I take the normal form for the vector field and see if my normal form computation gives the same. See [hopf test](https://github.com/bifurcationkit/BifurcationKit.jl/blob/master/test/testNF.jl#L252), [transcritical](https://github.com/bifurcationkit/BifurcationKit.jl/blob/master/test/testNF.jl#L41), [pitchfork D6](https://github.com/bifurcationkit/BifurcationKit.jl/blob/master/test/testNF.jl#L182), [cusp](https://github.com/bifurcationkit/BifurcationKit.jl/blob/master/test/testNF.jl#L268), [bogdanov-takens](https://github.com/bifurcationkit/BifurcationKit.jl/blob/master/test/testNF.jl#L285), [bautin](https://github.com/bifurcationkit/BifurcationKit.jl/blob/master/test/testNF.jl#L362)

You can have access to more than what is given by `show(nf)` by looking at the fields of `nf` where `nf` is the normal form `nf = getNormalForm(br, ind::Int)`.

In a nutshell, I try to test as much as I can to test the code against analytics although the above tests are not perfect because they do not involve the computatation of the center manifold since it is the whole space. But that’s already a test ;D

> I am happy to know of a bug here because it will become one less in the package

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [September 16, 2022, 1:53pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/27 "2022-09-16T13:53:55Z")

</div>

Okay, thank you. I wonder what this may indeed be a bautin bifurcation. I test critical parametres and see next attractor. the Lyapunov spectrum and the eigenvalues indicate that this is indeed a bautin bifurcation if of course believe the results of the calculation. Before critical value i have not zero real numbers but i have zero largest lyapunov exponent.  
for calculate fixed point and spectrum uses DynamicalSystems.jl

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/a/5ad666786b563e46402eb73b4baa6c99e0eec997.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/6/46c4c962b807a31efd4139ec28eae18ef1096557.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/f/5f8aff9f8f23d5bb1584d78970bbad9b20a6f419.png)

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 16, 2022, 1:58pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/28 "2022-09-16T13:58:40Z")

</div>

You are making a link between unrelated behaviors to my mind. It is more sophisticated than just a bauti and likely involve periodic orbits and torus.

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [September 16, 2022, 2:02pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/29 "2022-09-16T14:02:30Z")

</div>

perhaps this is so, I hardly understand what is happening in the system, because there is only one state of equilibrium, which practically does not affect the dynamics in any way  
I’ll attach another projection. perhaps you know what it is

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/c/acce4624acdf5c58a52f95bb5aa0f5791ea7dfd2.png)

---

<div class="post-metadata">

**Author:** ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Post date:** [September 16, 2022, 2:12pm UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/30 "2022-09-16T14:12:47Z")

</div>

I take parameter before critical value and get this. could it be unrelated to the state of equilibrium?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/9/09903aaedc0fafc5062404ac4fc04e1a614d137b.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/8/288a15753ba875959237acc8daa89f7f4a191d05.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/f/3f51900838328f61d97e0c03190aa57faf716d05.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/3/53e18e20787ec07f5fe4b7be384578a46932a58a.png)

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 22, 2022, 8:19am UTC](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259/31 "2022-09-22T08:19:27Z")

</div>

I’d compute the curve of periodic orbits from the Hopf point

[Previous page](https://discourse.julialang.org/t/incorrect-bifurcation-diagram-bifurcationkit-jl/87259.md?page=1)
