# Detecting pitchfork bifurcations from side branch

**URL:** <https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558>\
**Category:** Modelling & Simulations\
**Tags:** bifurcationkit\
**Created:** [March 31, 2025, 4:00pm UTC](https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558 "2025-03-31T16:00:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [March 31, 2025, 4:00pm UTC](https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558/1 "2025-03-31T16:00:04Z")

</div>

@rveltz Is BifurcationKit.jl capable of detecting a pitchfork bifurcation when the continuation approaches along a side branch? I always use `detect_bifurcation=3` as you suggested on slack, and have spent more time than I should exploring the continuation parameter space, but have very rarely had success with this. MWE:

```julia
using BifurcationKit, Plots

f(x, p) = @. -x^3 - p * x
prob = BifurcationProblem(
	f, [1.0], -1.0; record_from_solution=(x, p; _...) -> x[1]
)
contp = ContinuationPar(
	p_min=-1.0,
	p_max=1.0,
	dsmax=5e-2,
	detect_bifurcation=3,
)
br = continuation(prob, PALC(), contp; bothside=true)
plot(br)

```

**Result**

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

If I relax `dsmax`, the continuation may jump to the central branch and continue to the right, but in any case, the bifurcation is not detected.

I’m not surprised that this doesn’t work. Along this branch, no eigenvalue changes sign; it only tangentially touches zero before growing back with the same sign. Even so, the bifurcation is technically detectable since `tol_stability > 0`, but in practice, I find that I need to take _extremely_ small steps for reliable detection—for this MWE, I need `dsmax <= 2e-5`, resulting in more than `100_000` steps to complete the continuation of this branch.

It’s OK if this is simply a hard problem that numerical continuation can’t reliably help with. Just curious if there’s an approach that might be more successful.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [March 31, 2025, 4:21pm UTC](https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558/2 "2025-03-31T16:21:42Z")

</div>

> [@danielwe](#):
>
> I need to take _extremely_ small steps for reliable detection—for this MWE, I need `dsmax <= 2e-5`

This solution is also unsatisfactory because it detects two bifurcations rather than one:

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

Trying to branch off of these points, for example using `bifurcationdiagram`, is likely to create a mess and may not even locate the central branch.

---

<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:** [March 31, 2025, 6:17pm UTC](https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558/3 "2025-03-31T18:17:14Z")

</div>

Oh I see what you mean now!  
`detect_bifurcation` is based on a change of stability but there is no one along the branch. The only way to see it is through the fold and compute the normal form

---

<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:** [March 31, 2025, 6:30pm UTC](https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558/4 "2025-03-31T18:30:50Z")

</div>

This is a Bug

---

<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:** [April 2, 2025, 8:37pm UTC](https://discourse.julialang.org/t/detecting-pitchfork-bifurcations-from-side-branch/127558/5 "2025-04-02T20:37:52Z")

</div>

> <https://github.com/bifurcationkit/BifurcationKit.jl/issues/223>
>
> Is \[BifurcationKit.jl\](https://juliaregistries.github.io/General/packages/redire…ct\_to\_repo/BifurcationKit) capable of detecting a pitchfork bifurcation when the continuation approaches along a side branch? I always use detect\_bifurcation=3 as you suggested on slack, and have spent more time than I should exploring the continuation parameter space, but have very rarely had success with this. MWE:
> 
> \`\`\`julia
> using BifurcationKit, Plots
> 
> f(x, p) = @. -x^3 - p \* x
> prob = BifurcationProblem(
> f, \[1.0\], -1.0; record\_from\_solution=(x, p; \_...) -\> x\[1\]
> )
> contp = ContinuationPar(
> p\_min=-1.0,
> p\_max=1.0,
> dsmax=5e-2,
> detect\_bifurcation=3,
> )
> br = continuation(prob, PALC(), contp; bothside=true)
> plot(br)
> \`\`\`
> 
> \<img width="593" alt="Image" src="https://github.com/user-attachments/assets/ca0cbc8e-32fe-4963-b29d-1abaa81a89e5" /\>
> 
> 
> If I relax dsmax, the continuation may jump to the central branch and continue to the right, but in any case, the bifurcation is not detected.
> 
> I’m not surprised that this doesn’t work. Along this branch, no eigenvalue changes sign; it only tangentially touches zero before growing back with the same sign. Even so, the bifurcation is technically detectable since tol\_stability \> 0, but in practice, I find that I need to take extremely small steps for reliable detection—for this MWE, I need dsmax \<= 2e-5, resulting in more than 100\_000 steps to complete the continuation of this branch.
> 
> It’s OK if this is simply a hard problem that numerical continuation can’t reliably help with. Just curious if there’s an approach that might be more successful.
