Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoine-levitt/7907faca2d72238a452de537779efbb0 to your computer and use it in GitHub Desktop.
Save antoine-levitt/7907faca2d72238a452de537779efbb0 to your computer and use it in GitHub Desktop.
using PseudoArcLengthContinuation, LinearAlgebra, Plots, PyPlot, Optim
const PALC = PseudoArcLengthContinuation
# fonction à annuler
function f(x, alpha)
resu = zeros(1)
resu[1]= alpha*x[1] + x[1]^3
return resu
end
function df(x, alpha)
resu = zeros(1,1)
resu[1,1] = alpha + 3*x[1]^2
end
# option pour Newton
optnewton = NewtonPar(verbose = true)
sol = zeros(1)
sol[1] = 100.
# résolution
alpha_min = -10.
alpha_max = 10.
alpha_start = -1.
out, _, _ = @time newton( x -> f(x, alpha_start), sol, optnewton)
optcont = ContinuationPar(dsmin = 0.01, dsmax = 0.15, ds= 0.01, pMax = alpha_max , pMin = alpha_min, newtonOptions = NewtonPar(tol = 1e-9))
br, _ = continuation((x, p) -> f(x, p), out, alpha_start , optcont, plot = true, printSolution = (x,p) -> x[1], plotSolution = (x, p;kwargs...) -> (plot!(x; ylabel="solution",label="",kwargs...)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment