Created
May 20, 2020 08:48
-
-
Save antoine-levitt/7907faca2d72238a452de537779efbb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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