Finding multiple fixed points of a non-linear problem

Hi! I’m looking for some Julia code that will find all the fixed points of a non-linear problem.

Specifically, I’m looking for all the solutions of this fixed point problem:

m = tanh(am + b)

where a and b are parameters. I want to highlight the solutions on a interactive plot of m and tanh(am +b), where the user can tweak a and b and see how the number and location of the fixed points change.
I know that for this example, the number of fixed points must be between 1 and 3 inclusive, which might help.

At the moment I am suing NLsolve and that finds one fixed point very nicely, but I wonder if there is a way to using NLsolve to search for up to N (=3) fixed points. I know that I could use NLsolve three times with three different initial guesses, but the interaticivity is already pretty slow and that would only make it worse (and need lots of handling to cope with the variable size of output, etc).

ATM my code looks something like this in my Pluto notebook:

begin 
function consistency_solve!(F, x)
	F[1] = consistency(λ2, x[1], λ1)
end

res = fixedpoint(consistency_solve!, [0.0]; method = :anderson, autodiff = :forward)

upper = plot(x -> x, -2.0:2.0, label = "m", xlabel = "m", legend_position =  :topleft)
plot!(upper, x -> consistency(λ2, x, λ1), color = :green, label = "tanh(λ1*m + λ2)")
scatter!(upper, res.zero, res.zero, color = :orange, label = "Fixed Point")
end

λ2,1 are bound as parameters in the workbook.

Thank you in advance for any ideas!

Check https://github.com/JuliaIntervals/IntervalRootFinding.jl

1 Like

If you only have a single-variable function, ApproxFun.jl can do this (on a given interval) via its roots function. See the first example in its documentation.

1 Like

Thanks both! That’s really helpful.

1 Like