# Issues with continuation in BifurcationKit

**URL:** <https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 20, 2024, 2:42pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852 "2024-11-20T14:42:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmplac14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmplac14/32/213427_2.png) [@mmplac14](https://discourse.julialang.org/u/mmplac14)\
**Post date:** [November 20, 2024, 2:42pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/1 "2024-11-20T14:42:25Z")

</div>

Hi!

I am new to Julia and BifurcationKit. I am trying to perform a bifurcation analysis of the Jansen-Rit model as was done by Grimbert and Faugueras but I keep running into this error when calling `continuation`

```julia
The function iterate_from_two_points exists, but no method is defined for this combination of argument types.
Closest candidates are:
  iterate_from_two_points(::ContIterable, ::Any, ::T, ::Any, !Matched::T; _verbosity) where T
   @ BifurcationKit ~/.julia/packages/BifurcationKit/RaJtn/src/Continuation.jl:382

```

I have tried some of the tutorials on the BifurcationKit website, but this steps works fine. I am using Jupyter Notebook in VSCode if it makes a difference. If someone could provide some guidance I would greatly appreciate it!

Here is the full code:

```julia
using Revise, Plots
using BifurcationKit

const BK = BifurcationKit

# Define the function σ
function σ(v, e0 = 2.5, v0 = 6, r=0.56)
    2 * e0 / (1 + exp(r * (v0 - v)))
end

# vector field
function jansenrit(z, param)
	(;A, a, B, b, C1, C2, C3, C4, p) = param
	y0, y3, y1, y4, y2, y5 = z
	[
	    y3
        A * a * σ(y1 - y2) - 2 * a * y3 - a^2 * y0
        y4
        A * a * (p + C2 * σ(C1 * y0)) - 2 * a * y4 - a^2 * y1
        y5
        B * b * C4 * σ(C3 * y0) - 2 * b * y5 - b^2 * y2
	]
end

# parameter values
C= 135
par = (A = 3.25, a = 100, B = 22, b = 50, C1 = C, C2 = 0.8 * C, C3 = 0.25 * C, C4 = 0.25 * C, p = 50)

# initial condition
z0 = [0.0, 0.0, 15.0, 0.0, 10.0, 0.0]

# Bifurcation Problem
prob = BifurcationProblem(jansenrit, z0, par, (@optic _.p);
	record_from_solution = (x, p; k...) -> (y0 = x[1], y3 = x[2], y1 = x[3], y4 = x[4], y2 = x[5], y5 = x[6]),)

opts_br = ContinuationPar(p_min =1.0, p_max = 400.0)

# continuation options, we limit the parameter range for p
opts_br = ContinuationPar(p_min =1.0, p_max = 400.0)

# continuation of equilibria
br = continuation(prob, PALC(), opts_br;
	# we want to compute both sides of the branch of the initial
	# value of p = 100
	bothside = false, verbosity = 3)

```

---

<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:** [November 20, 2024, 3:00pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/2 "2024-11-20T15:00:50Z")

</div>

it is because `par.p` is an `Int`. Use `par = (A = 3.25, a = 100, B = 22, b = 50, C1 = C, C2 = 0.8 * C, C3 = 0.25 * C, C4 = 0.25 * C, p = 50.0)`

---

<div class="post-metadata">

**Author:** ![mmplac14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmplac14/32/213427_2.png) [@mmplac14](https://discourse.julialang.org/u/mmplac14)\
**Post date:** [November 21, 2024, 10:29am UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/3 "2024-11-21T10:29:17Z")

</div>

Thank you Romain! Now I am confused about how to set the range for p. Even though I have set p\_min =0.0 and p\_max =400.0, it only goes from 50 to ~110. I assume the 50 comes from the initial parameter values set in ‘par’. I have tried different settings for dsmax, ds\_min, ds but I can only increase the range so much.

```julia
# continuation options, we limit the parameter range for p
opts_br = ContinuationPar(p_min =0.0, p_max = 400.0, dsmax = 2.0, dsmin= 0.001, ds = 0.001, max_steps = 1000)

# continuation of equilibria
br = continuation(prob, PALC(), opts_br;
	# we want to compute both sides of the branch of the initial
	# value of p = 100
	bothside = false, verbosity = 3)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/1/f146b4cbbbb5104e2787ea210242b5f876ee6fb4.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:** [November 21, 2024, 4:05pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/4 "2024-11-21T16:05:15Z")

</div>

`br` does not contain `1000` points? What is the last continuation step printed in the REPL?

---

<div class="post-metadata">

**Author:** ![mmplac14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmplac14/32/213427_2.png) [@mmplac14](https://discourse.julialang.org/u/mmplac14)\
**Post date:** [November 21, 2024, 4:51pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/5 "2024-11-21T16:51:57Z")

</div>

No, it only had 308 points. I managed to fix it though by lowering the Newton tolerance to e-9. Now I am able to get to the max\_steps I specify.

Do you think it might have been failing to converge before? It wasn’t logging anything apart from a “5-element Vector{ComplexF64}” (I don’t know what this vector is) so it is difficult to say what was happening.

---

<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:** [November 21, 2024, 4:58pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/6 "2024-11-21T16:58:20Z")

</div>

You can tell this by passing `NewtonPar(verbose = true)`. You can also use the `normC = norminf` instead of the 2-norm. Please tell us if this is newton tolerance that was too small.

---

<div class="post-metadata">

**Author:** ![mmplac14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmplac14/32/213427_2.png) [@mmplac14](https://discourse.julialang.org/u/mmplac14)\
**Post date:** [November 22, 2024, 10:33am UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/7 "2024-11-22T10:33:51Z")

</div>

Is doing `normC = norminf` equivalent to passing `NewtonPar(verbose = true)`? The outputs seems slightly different, but it does seem like tolerance is the issue

With `normC = norminf`:

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

And with `NewtonPar(verbose = true)`:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/0/9073f5d5a88452e9a2bc22042f2dc0ea491a9c59.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:** [November 22, 2024, 2:26pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/8 "2024-11-22T14:26:05Z")

</div>

Hi

No NewtonPar contains the newton parameters. Above you just specify that you want newton to output it’s iterations.

But judging from your screenshots, you don’t see them. Are you using Pluto.jl?

---

<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:** [November 22, 2024, 2:48pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/9 "2024-11-22T14:48:20Z")

</div>

> [@mmplac14](#):
>
> ```julia
> br = continuation(prob, PALC(), opts_br;
> # we want to compute both sides of the branch of the initial
> # value of p = 100
> bothside = false, verbosity = 3)
> 
> ```

basically, I was suggesting to do

```julia

br = continuation(prob, PALC(), ContinuationPar(opts_br, newton_options = NewtonPar(tol = 1e-11, verbose = true));
	# we want to compute both sides of the branch of the initial
	# value of p = 100
        normC = norminf,
	bothside = false, verbosity = 3)

```

---

<div class="post-metadata">

**Author:** ![mmplac14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mmplac14/32/213427_2.png) [@mmplac14](https://discourse.julialang.org/u/mmplac14)\
**Post date:** [November 22, 2024, 3:11pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/10 "2024-11-22T15:11:30Z")

</div>

Hey!

The iterations get printed but not always, perhaps because I am using a Jupyter Notebook.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/f/bf05e473ccc409f72b7d785731a7fa31f05f52cc.png)

Do you recommend Pluto?

---

<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:** [November 23, 2024, 1:19pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/11 "2024-11-23T13:19:10Z")

</div>

Ah that’s why. I use vscode where all iterations are printed.

---

<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:** [November 23, 2024, 1:19pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852/12 "2024-11-23T13:19:25Z")

</div>

I do not use pluto
