CoCalc Public Filesjulia-1.4.ipynbOpen with one click!
Author: Harald Schilly
Views : 252
Compute Environment: Ubuntu 18.04 (Deprecated)
In [1]:
VERSION
v"1.4.2"
In [2]:
println("Hello 1.4")
Hello 1.4
In [6]:
using FFTW using LinearAlgebra a = 2 * rand(10) .- 1 norm(ifft(fft(a)) - a)
1.5203344565649012e-16
In [4]:
using PyCall # pygui(true) using PyPlot import Random:seed!; seed!(99) import LinearAlgebra:norm function activate(x,W,b) return 1 ./ (1 .+ exp.(-(W*x+b))) end x1 = [0.1,0.3,0.1,0.6,0.4,0.6,0.5,0.9,0.4,0.7] x2 = [0.1,0.4,0.5,0.9,0.2,0.3,0.6,0.2,0.4,0.6] y = [ones(1,5) zeros(1,5) ; zeros(1,5) ones(1,5)] W2 = 0.5*randn(2,2); W3 = 0.5*randn(3,2); W4 = 0.5*randn(2,3); b2 = 0.5*randn(2,1); b3 = 0.5*randn(3,1); b4 = 0.5*randn(2,1);
In [5]:
PyPlot.plot(x1, x2)
1-element Array{PyObject,1}: PyObject <matplotlib.lines.Line2D object at 0x7fa04c118dd8>
In [12]:
using Pkg
In [7]:
for i = 1:10 println(i) end
1 2 3 4 5 6 7 8 9 10
In [8]:
using NLopt function myfunc(x::Vector, grad::Vector) if length(grad) > 0 grad[1] = 0 grad[2] = 0.5/sqrt(x[2]) end return sqrt(x[2]) end function myconstraint(x::Vector, grad::Vector, a, b) if length(grad) > 0 grad[1] = 3a * (a*x[1] + b)^2 grad[2] = -1 end (a*x[1] + b)^3 - x[2] end opt = Opt(:LD_MMA, 2) opt.lower_bounds = [-Inf, 0.] opt.xtol_rel = 1e-4 opt.min_objective = myfunc inequality_constraint!(opt, (x,g) -> myconstraint(x,g,2,0), 1e-8) inequality_constraint!(opt, (x,g) -> myconstraint(x,g,-1,1), 1e-8) (minf,minx,ret) = optimize(opt, [1.234, 5.678]) numevals = opt.numevals # the number of function evaluations println("got $minf at $minx after $numevals iterations (returned $ret)")
got 0.5443310477213124 at [0.3333333342139688, 0.29629628951338166] after 11 iterations (returned XTOL_REACHED)
In [ ]:
In [9]:
using Printf s = 0 for i = [1 2 5 100 -1 5] s = s + i @printf("i = %4d → s = %4d\n", i, s) end
i = 1 → s = 1 i = 2 → s = 3 i = 5 → s = 8 i = 100 → s = 108 i = -1 → s = 107 i = 5 → s = 112
In [2]:
using Pkg Pkg.add("Turing")
Resolving package versions... Updating `~/.julia/environment/v1.4/Project.toml` [no changes] Updating `~/.julia/environment/v1.4/Manifest.toml` [no changes]
In [3]:
# Import libraries. using Turing, StatsPlots, Random
┌ Info: Precompiling Turing [fce5fe82-541a-59a6-adf8-730c64b5f9a0] └ @ Base loading.jl:1260 ERROR: LoadError: LoadError: ERROR: LoadError: InterruptException: Stacktrace: [1] top-level scope at /home/user/.julia/packages/DynamicPPL/E1QSS/src/compiler.jl:371 [2] include(::Module, ::String) at ./Base.jl:377 [3] include(::String) at /home/user/.julia/packages/DynamicPPL/E1QSS/src/DynamicPPL.jl:1 [4] top-level scope at /home/user/.julia/packages/DynamicPPL/E1QSS/src/DynamicPPL.jl:103 [5] include(::Module, ::String) at ./Base.jl:377 [6] top-level scope at none:2 [7] eval at ./boot.jl:331 [inlined] [8] eval(::Expr) at ./client.jl:449 [9] top-level scope at ./none:3 in expression starting at /home/user/.julia/packages/DynamicPPL/E1QSS/src/compiler.jl:371 in expression starting at /home/user/.julia/packages/DynamicPPL/E1QSS/src/DynamicPPL.jl:103 InterruptException: Stacktrace: [1] poptaskref(::Base.InvasiveLinkedListSynchronized{Task}) at ./task.jl:702 [2] wait at ./task.jl:709 [inlined] [3] wait(::Base.GenericCondition{Base.Threads.SpinLock}) at ./condition.jl:106 [4] wait(::Base.Process) at ./process.jl:622 [5] success at ./process.jl:483 [inlined] [6] compilecache(::Base.PkgId, ::String) at ./loading.jl:1262 [7] _require(::Base.PkgId) at ./loading.jl:1029 [8] require(::Base.PkgId) at ./loading.jl:927 [9] require(::Module, ::Symbol) at ./loading.jl:922 [10] include(::Module, ::String) at ./Base.jl:377 [11] top-level scope at none:2 [12] eval at ./boot.jl:331 [inlined] [13] eval(::Expr) at ./client.jl:449 [14] top-level scope at ./none:3 in expression starting at /home/user/.julia/packages/Turing/cReBm/src/Turing.jl:18
Failed to precompile Turing [fce5fe82-541a-59a6-adf8-730c64b5f9a0] to /home/user/.julia/compiled/v1.4/Turing/gm4QC_G6IaO.ji. Stacktrace: [1] error(::String) at ./error.jl:33 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272 [3] _require(::Base.PkgId) at ./loading.jl:1029 [4] require(::Base.PkgId) at ./loading.jl:927 [5] require(::Module, ::Symbol) at ./loading.jl:922 [6] top-level scope at In[3]:1
In [20]:
# Set the true probability of heads in a coin. p_true = 0.5 # Iterate from having seen 0 observations to 100 observations. Ns = 0:100; # Draw data from a Bernoulli distribution, i.e. draw heads or tails. Random.seed!(12) data = rand(Bernoulli(p_true), last(Ns)) # Declare our Turing model. @model coinflip(y) = begin # Our prior belief about the probability of heads in a coin. p ~ Beta(1, 1) # The number of observations. N = length(y) for n in 1:N # Heads or tails of a coin are drawn from a Bernoulli distribution. y[n] ~ Bernoulli(p) end end; # Settings of the Hamiltonian Monte Carlo (HMC) sampler. iterations = 1000 ϵ = 0.05 τ = 10 # Start sampling. chain = sample(coinflip(data), HMC(ϵ, τ), iterations); # Plot a summary of the sampling process for the parameter p, i.e. the probability of heads in a coin. histogram(chain[:p])
┌ Info: Precompiling Turing [fce5fe82-541a-59a6-adf8-730c64b5f9a0] └ @ Base loading.jl:1260
InterruptException: Stacktrace: [1] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:681 [2] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:781 [3] _tryrequire_from_serialized(::Base.PkgId, ::UInt64, ::String) at ./loading.jl:712 [4] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:770 [5] _tryrequire_from_serialized(::Base.PkgId, ::UInt64, ::Nothing) at ./loading.jl:712 [6] _require_from_serialized(::String) at ./loading.jl:743 [7] _require(::Base.PkgId) at ./loading.jl:1039 [8] require(::Base.PkgId) at ./loading.jl:927 [9] require(::Module, ::Symbol) at ./loading.jl:922 [10] top-level scope at In[20]:1
In [4]:
using Compat
In [5]:
using PyPlot x = range(0, stop = 4*pi, length=1000) y = sin.(3*x + 1.5*cos.(2*x)) plot(x, y, color="red", linewidth=2.0, linestyle="--")
1-element Array{PyCall.PyObject,1}: PyObject <matplotlib.lines.Line2D object at 0x7f08fa1982e8>
In [10]:
using SymPy x = symbols("x") # or @vars x, Sym("x"), or Sym(:x) y = sin(10 * pi*x) y(1), y(2.2), y(123456)
(-1.22464679914735e-15, 4.41120439947682e-15, 6.39055017337619e-11)
In [11]:
simplify(diff(sqrt(2 + exp(x)) / (1 + x - cos(x)^2), x))
In [12]:
using Test foo(x) = length(x)^2 α = 1 @testset "foo" begin @test α == 2-1 @test π 3.14 atol=0.01 @test isapprox(9.81, 10, atol=0.2) @test foo("foo") == 9 end
Test Summary: | Pass Total foo | 4 4
Test.DefaultTestSet("foo", Any[], 4, false)
In [ ]:
using SpecialMatrices
In [ ]:
using ApproxFun
In [ ]:
using HomotopyContinuation, LinearAlgebra, DynamicPolynomials = 2 @polyvar z[1:3, 1:6] z_vec = vec(z)[1:17] # the 17 variables in a vector Z = [zeros(3) z[:,1:5] [z[1,6]; z[2,6]; 0] [; 0; 0]] # the eight points in a matrix # define the functions for cyclooctane: F1 = [(Z[:, i] - Z[:, i+1]) (Z[:, i] - Z[:, i+1]) - for i in 1:7] F2 = [(Z[:, i] - Z[:, i+2]) (Z[:, i] - Z[:, i+2]) - 8/3 for i in 1:6] F3 = (Z[:, 7] - Z[:, 1]) (Z[:, 7] - Z[:, 1]) - 8/3 F4 = (Z[:, 8] - Z[:, 2]) (Z[:, 8] - Z[:, 2]) - 8/3 f = [F1; F2; F3; F4]
In [2]:
n = 2 # dimension of the cyclooctane variety N = 17 # ambient dimension @polyvar Aᵥ[1:n, 1:N] bᵥ[1:n] # variables for the linear equations p = [vec(Aᵥ); bᵥ] # parameters F = [f; Aᵥ * z_vec - bᵥ] # the polynomial system we have to solve # now we solve one particular instance for A,b complex. we use this as start system A₀ = randn(ComplexF64, n, N) b₀ = randn(ComplexF64, n) p₀ = [vec(A₀); b₀] F₀ = [subs(Fᵢ, p => [vec(A₀); b₀]) for Fᵢ in F] complex_result = solve(F₀) S_p₀ = solutions(complex_result)
Tracking 32768 paths... 100%|████████████████████████████████████████| Time: 0:02:32 # paths tracked: 32768 # non-singular solutions (real): 1408 (0) # singular solutions (real): 0 (0) # total solutions (real): 1408 (0)
1408-element Array{Array{Complex{Float64},1},1}: [-0.47140452079103157 - 2.422449305177514e-18im, -0.16384237851714517 + 0.2552019284126488im, 1.3479702017333817 + 0.03101915079392895im, -1.0455095604262024 + 0.7933755866659716im, 1.2898783954781725 + 0.5587198843935196im, 1.8765476693717755 + 0.05797937064992404im, 24.735366995427633 + 10.625824542195016im, 13.310996213665462 - 2.2224614153547333im, 9.827663410548107 - 27.61816720417769im, 0.13149256848157667 - 0.08445250104374812im, -0.8930876777097178 + 0.12398508334875953im, 1.450721420349676 - 0.13974025496718226im, 1.1135955726342797 - 0.5858587155439727im, -2.106284509545492 - 0.2071323352891917im, 1.2046193901745286 - 0.5083757604920134im, 1.8856180831641267 + 1.2683105876356778e-43im, -1.3333333333333335 + 1.793662034335766e-43im] [-0.47140452079103057 - 6.617828928240829e-16im, -3.4086937947479607 + 2.5181841839755585im, 2.6476833435081675 + 3.2419733360472622im, 2.5052403040075135 + 0.1920065064866999im, 0.34199759439431754 - 0.23177461391707674im, 0.3806202039800047 - 1.0555300903100622im, 1.0604368575965808 + 0.1813209001237161im, 0.7244859857994322 + 0.08213632080142466im, 0.09103514155742315 - 0.5875988778656646im, 0.4465579687900144 + 0.6476897145769915im, 4.79744224240648 - 5.724939885807321im, 6.0270695309569495 + 3.4451037258524315im, 3.2349050935787584 + 0.17689811281980478im, 1.3562883359177793 - 0.06254292757699345im, 0.6060818337742233 - 0.39144986618892147im, 1.885618083164127 + 0.0im, 1.333333333333333 - 1.6704779438076223e-51im] [-0.4714045207910317 + 2.0265282535324248e-18im, 1.4773118749787342 + 0.7797185937458206im, -1.1216094256359357 + 1.026995236803861im, -2.2507985671884665 + 0.3579302939650492im, 2.6287604507363715 + 1.3908381809685333im, -1.16891160450314 + 2.438637275661215im, 20.6209669699364 + 7.35413255413667im, 9.82345482600752 - 5.648918321982728im, 3.7300723799894397 - 19.885706215985092im, 5.266097571367884 + 4.762458605040116im, 3.941114654838942 - 0.23080641337503524im, 3.2104992837992636 - 4.635421437460402im, 1.7553112553381764 - 4.130805237382327im, -1.8794037541286512 - 1.4604601975569742im, -4.578911118624116 + 0.29172574153093483im, 1.8856180831641265 + 0.0im, -1.3333333333333335 - 1.925929944387236e-34im] [-0.47140452079103146 - 2.9755607998039095e-16im, 0.8886951346725742 - 3.4915979380683106im, -3.724685166573224 - 0.8330814447463443im, 2.248718886520195 - 0.23113787677353967im, 0.6928360631182762 + 0.47195333111145976im, -0.4822327174738021 - 0.3997609743235411im, 3.4150634530832296 - 0.35845638381154493im, 1.0840990026314485 + 0.4974622293345537im, -1.2164062403990406 - 0.5884310340286092im, 2.4033789269324797 - 0.5487946839409098im, 2.261177235656359 + 1.9132022864498959im, -2.9033786108394826 + 0.5135426262402145im, 1.0816482703900105 - 0.44783421615315244im, 2.1175795865742613 + 0.1583333055446281im, -1.0795389380040465 + 0.4485410164513247im, 1.8856180831641265 + 2.7369110631344083e-48im, 1.3333333333333335 + 5.473822126268817e-48im] [-0.4714045207910317 + 1.6286824538045384e-17im, 1.5772014810731512 - 0.10584727853837796im, -0.19453682572018186 - 0.8581536367742478im, 7.513661184838595 - 7.634562016147988im, 0.9596918442067405 + 2.934447625084449im, 7.904306671483201 + 6.900965397474049im, 3.4899040302558353 + 0.8479103731336467im, 2.670611902234994 - 0.07333065249240625im, -1.1822719130217272 + 2.578383824569445im, 8.139247137286468 - 0.10790812357479694im, 2.5760663420893133 + 0.4647039212636588im, -0.1633664806374005 + 6.98978136602634im, 11.807711287176083 + 7.413843749082465im, 1.674656360727566 + 2.62118959481686im, -7.9050689147039295 + 10.30292851897507im, 1.8856180831641265 + 0.0im, -1.3333333333333335 - 4.3790577010150533e-47im] [-0.47140452079103273 - 2.300198559466298e-16im, 0.6864263968540075 + 8.293384853722484im, -8.39917942631617 + 0.6777802918494329im, -2.1527879309937235 - 0.024799481351254173im, 0.8647872671915876 + 13.489633620771004im, -13.515680610851247 + 0.8670707569888416im, 6.173243179922792 + 2.035582328461635im, 4.182870492767442 - 0.7043149550745138im, -1.936910481147947 + 3.4530016710606244im, 4.916750580363144 + 1.2868171608914283im, 2.953858516527601 - 0.46747574906528566im, -1.2622941390540123 + 2.4898769575163184im, -4.945358476758881 - 4.233992247692672im, 4.248448257157288 + 1.4969423149173797im, 4.5445854232569936 - 7.324333812906591im, 1.885618083164127 + 5.345529420184391e-51im, 1.333333333333333 + 4.276423536147513e-50im] [-0.47140452079103096 - 3.567553603052717e-16im, -2.6591470212879242 + 2.227908580596266im, -2.400369858953108 - 2.4680931747652393im, -2.2874026513483465 + 0.41936124226406835im, -1.4814373075800487 - 1.7005716515192872im, 1.45652558152636 - 1.0710709726850682im, -0.6911665099096699 + 0.48937338394048246im, -1.542264281655869 - 1.0901195097569725im, 1.6226759959309947 - 1.5202058999093628im, -0.1548732137313416 - 0.23790971062048658im, -0.03880849489265388 - 0.7587270155365943im, 1.2192946833278848 - 1.2519809928346468im, 2.2201321780921885 - 2.474438187591074im, 1.715064740870276 + 0.874846011036299im, 2.9425736730194982 + 0.16780489003009705im, 1.885618083164127 - 1.5482306977974587e-47im, 1.3333333333333333 - 2.1895288505075267e-47im] [-0.4714045207910311 + 3.3320935660482274e-16im, -2.6116311888968333 + 2.6481641874217603im, -2.823257257925051 - 2.4496627665709902im, 2.0315768314827345 - 1.022370882693332im, -2.487471429587334 - 1.485838735638739im, 0.9853628910797673 - 1.6430052522468568im, 0.7328330295247414 + 0.5252640701489933im, -0.2477945796018222 - 0.3731159530770196im, 0.5549378940505199 - 0.5228143776804759im, 0.7396893182526616 + 0.7044135578346908im, 0.1645838635805236 - 1.256950665922701im, 2.1957203480458554 - 0.30142848863938165im, 2.324296457074964 - 0.43847509040642757im, 1.6782371068572128 + 0.15502435490388478im, 1.3838236271851092 + 0.10036037247604107im, 1.885618083164127 - 2.5366211752713563e-43im, 1.3333333333333333 - 3.587324068671532e-43im] [-0.47140452079103146 - 1.3895044915021593e-18im, -1.335890569804467 + 0.005446137141163444im, 0.06805731679703328 + 0.10690170566729205im, -32.56901144352285 - 0.6808675495405753im, 12.285114172023555 - 1.4676285758911252im, 0.11947612994623184 - 34.694782944752376im, -45.83369328550179 - 0.4883888317559811im, 16.43877656924994 - 2.247020613452205im, -0.29979964551946986 - 48.5055029784775im, 20.74485489831559 + 2.2684050123980266im, 3.225160943348284 + 0.8094409673313138im, -2.41217448523765 + 19.264866460853934im, 15.173467967107053 + 1.7561867821854384im, 2.8646310468291376 + 0.6209057913567545im, -1.8711592773154386 + 13.864392539910838im, 1.885618083164127 + 0.0im, -1.333333333333333 - 4.1053665947016125e-48im] [-0.47140452079103234 - 1.48494788334529e-16im, -2.1321941790979047 + 3.3216418634645275im, -3.511728160202213 - 2.01678066274901im, -3.7115646937842848 - 0.25710592174231744im, 4.432668088864209 - 5.560522943832396im, 5.018480440792388 + 4.7212871761397945im, -0.5839432822328432 + 2.1189981619411404im, -3.436569392014171 - 4.3853345270613495im, 4.78916307730214 - 3.1991018450033093im, 1.0324475727115994 + 0.5480863469636449im, -0.6907063956653368 - 1.3096943629866031im, 1.945265269979719 - 1.122346833006595im, 2.911588663051653 - 0.6864976297006655im, 1.470597956165151 + 0.24271356461491575im, 1.3116557204861254 + 0.5115750839585271im, 1.8856180831641265 + 0.0im, 1.3333333333333335 + 1.0947644252537633e-47im] [-0.47140452079103123 + 1.800367303959766e-16im, -4.470345281992293 + 1.0144142475471183im, 1.0600363974437998 + 4.277949282159855im, -2.0642114969803913 + 0.09112977685171064im, -6.549832027046168 + 2.0840909533055947im, 2.1345139107594227 + 6.4832357084097im, 4.383721104508967 + 13.3963237475702im, 2.001990454131207 + 5.098167732735239im, 14.550240623489463 - 2.5026936791037415im, 2.747295481212146 + 6.048755491179877im, -0.049421767730014464 + 2.4538468628769685im, 6.735026740919506 - 0.2700815744569385im, 4.44619899664865 + 0.1526755435183386im, 0.9280312694824582 - 0.053978956071579536im, 0.18979999913225096 - 2.1750045673162197im, 1.885618083164127 + 1.8991135491519597e-65im, 1.333333333333333 - 3.766090442565316e-49im] [-0.47140452079103173 + 7.010933011706144e-18im, 1.8684656742371537 - 0.11347034996560945im, -0.16135353569234026 - 1.3139808374492472im, -2.4611313950189286 + 0.06859151387109283im, 2.9687663711598917 - 0.33194675196250234im, -0.3732862158469987 - 3.092225304497094im, -27.913211905175068 + 23.73847238738448im, -3.6237255084478175 + 0.0577675404294527im, -23.697318574970673 - 29.0318609837352im, 32.360025937045215 + 26.931937717748976im, 7.220845948546794 + 9.466777412722408im, -28.556680607451785 + 31.576336826794446im, 22.01184529256957 + 16.539043261867427im, 5.282362536402532 + 5.847434822402057im, -17.562937615388726 + 21.15553793188266im, 1.8856180831641267 - 1.074978246869451e-49im, -1.333333333333333 - 1.8367099231598242e-40im] [-0.4714045207910316 + 2.539358446617602e-17im, -2.4408625852459354 - 0.17184876302519358im, -0.20485892299817093 + 2.0475516020980704im, -4.695157484945998 - 0.8763491473317039im, -6.828104392788758 - 1.6055790609002571im, -1.891148917978883 + 7.972750614127761im, 1.7354201168748786 - 0.5422894212011046im, -3.581381258956398 - 0.4283975799378729im, -1.0393241314966182 + 0.96405653263691im, 3.8654231953115428 - 0.3580617209297133im, -1.0233235271003092 + 0.10054786256799367im, -0.46075424850875885 - 2.05282802870513im, 6.703690278471654 - 0.6302619501381319im, 0.12988757255918093 + 0.2228312494332651im, -0.6936942731125423 - 4.764076954810238im, 1.885618083164127 - 3.331727228778685e-41im, 1.333333333333333 + 1.3775324423698682e-40im] ⋮ [-0.47140452079103273 + 1.487232845318346e-17im, 10.88950108741058 + 0.3075957345977921im, 0.3099258276925729 - 10.807631333352678im, -2.191382715291799 - 0.03577406569237183im, 2.0302786844858582 - 0.5668384073801581im, -0.5661131403660158 - 1.8944009427947364im, -1.6967433322661822 + 4.761153313169643im, 0.4274542103259507 + 13.733335335286661im, 14.551400759914884 - 0.5351880857121667im, -0.7867626723034191 - 3.9871411907328724im, -1.6607224784857588 - 12.0773043908925im, -12.695170867794152 + 1.1507633808055089im, 0.022160860458353672 + 0.08513808374804924im, -2.4921649526464837 + 0.030100858177736875im, 0.11523724343459366 + 1.6794310376080723im, 1.8856180831641265 - 1.1210387714598537e-42im, -1.3333333333333335 + 0.0im] [-0.4714045207910559 - 1.2005197150541992e-14im, -13.751899635430854 - 6.410429232465436im, -6.435291014356936 + 13.69877123322385im, 1.644519784414738 - 0.00533265054164792im, -5.963365146833487 - 2.766400322495339im, -2.852335018394182 + 5.780627278951667im, 1.7449485557768918 + 0.021193354285242848im, -0.22004174268853588 - 0.006280276537352325im, -0.02227636199887758 + 0.17829603523506016im, 0.3798523413764672 + 0.006293147483980801im, 0.4618692379558848 + 0.013303898838069504im, 0.036262684557079976 - 0.397300632560742im, -5.997012863349728 - 0.8972391259720628im, -4.620264231268774 - 0.317221935160369im, 0.9633644641093788 - 8.423905783668722im, 1.8856180831641265 + 0.0im, -1.3333333333333335 - 4.81482486096809e-35im] [-0.47140452079103157 - 3.700551347405851e-18im, 0.5989520060849287 - 0.7694575072567884im, -1.4531628167940602 - 0.31714830041228304im, 16.6463588008119 - 15.10212192410146im, 13.593175597712897 + 16.806256558056177im, 7.900427617641525 + 2.9042660446750275im, 2.3097045746362057 + 0.3352553775538161im, 0.9352378886640894 + 1.2676692962001601im, -3.100112471516534 + 0.6649331859246796im, 6.091913523788016 + 2.6015476855203783im, -1.0635409795350723 + 4.1972888770705055im, -4.4101894327463755 + 2.738039895571204im, 1.6561206406639946 + 1.8693712969449199im, -1.9144729322617395 + 0.6609225603126216im, -2.378619158054229 - 0.3418387515300963im, 1.8856180831641265 - 6.681911775230489e-52im, -1.3333333333333335 + 1.3363823550460978e-51im] [-0.4714045207910316 + 1.185827912993834e-16im, 2.6954373880679 + 0.7601180706392662im, -0.8617694499317842 + 2.3774928051920354im, -2.22001555146422 - 0.9293436233496956im, 1.1301347127812191 - 3.0836499086386344im, 3.115839083820108 + 0.45630806632786036im, -4.292904357705395 - 0.29191211896358615im, -5.678084546818632 - 1.7645001769438466im, 1.6392778634436493 - 6.520974756514536im, -2.776898727302369 + 0.6829526867712409im, -5.541634869705641 + 0.7590237020857036im, -1.089733307719156 - 5.85324771599831im, -0.9329759754078125 - 0.08151253389941951im, -2.8298568194474996 - 0.028819032735988917im, 0.09537685090042859 - 2.8610622022887715im, 1.885618083164127 + 9.283602326151913e-45im, -1.3333333333333333 + 4.484155085839415e-44im] [-0.47140452079103884 + 1.7267560490012465e-15im, 11.230247443894141 + 9.965231756361808im, 10.004622156988086 - 11.186031486609014im, -1.9464062014565708 - 0.0585630323236912im, 8.80112738473329 + 4.609141466059983im, 4.655763172651479 - 8.73747807132852im, 0.0187521779406926 + 6.1742340186782805im, -2.6870594339732863 + 12.810569376954856im, 12.97867155481487 + 1.1113751065252413im, -2.466170453248039 + 0.32047878816261427im, 4.904211942838711 - 0.004321318199414164im, -0.2748091280038824 - 5.1311498619236575im, -1.6426597218696564 + 0.8011682608651145im, 3.0807679142580207 - 0.2832557550645776im, -0.9009929712721436 - 3.6867269784176337im, 1.885618083164127 + 0.0im, 1.333333333333333 - 1.313717310304516e-46im] [-0.47140452079103046 - 6.441211506514118e-17im, 0.47376937019404364 - 2.2745004462363907im, 2.6258488407438008 + 0.4103772567556657im, 0.46771853735208724 - 0.1647008227296407im, 2.0231060595955905 - 2.942079456308727im, 3.5484519299029404 + 1.6990993601941211im, 3.3301231642061304 + 0.11391766687700794im, -3.3372219969969428 + 2.1726245092011287im, -1.20831403961599 - 3.8969237538886787im, -0.12858044049943673 - 0.37798130996381im, -0.14368940477257042 - 0.6556898780738335im, 0.6593096437994155 + 0.028375265163645604im, -0.15537895688629294 + 0.18903089253561425im, -2.5549347570339944 + 0.06683251298283913im, -0.24376997919658125 - 1.9176035814305168im, 1.8856180831641265 - 2.7369110631344083e-48im, -1.3333333333333335 - 4.3790577010150533e-47im] [-0.47140452079103157 - 1.1351938216604775e-16im, -2.7857072898350106 - 0.49558706416020326im, -0.5611977199716929 + 2.460025135969272im, -2.177708622693068 + 0.4779858714007512im, -4.869171774029243 + 0.1091290835328338im, 0.3279498422197408 + 4.794276454888891im, -3.726876029796859 - 1.9866085194030771im, -6.458362435325386 - 1.1277625312912658im, -2.600915084294718 + 6.769009346433019im, 11.733896916324952 - 13.828030370950867im, 0.6509864291032526 - 2.700240266433633im, -14.214785672241634 - 9.957268593008001im, -2.2615840628429766 - 4.816376320524954im, -3.299590713529849 - 1.7028461784947553im, -5.205966947276523 + 4.479997724623435im, 1.885618083164127 - 3.2405026987511395e-45im, -1.333333333333333 + 2.2420775429197073e-44im] [-0.47140452079103234 + 2.510756698590498e-16im, 4.7823056278977 - 1.8329304860716493im, -1.8977619148658884 - 4.618932285668284im, 2.082196300010177 - 0.02307781649569577im, 1.0174756687851196 - 0.06926460664296542im, -0.32178305153846515 - 0.36834629891211823im, 1.3961430281381828 + 0.11230403384981685im, -0.41839090421509045 + 0.037868200628707584im, -0.00419383095415092 + 0.40846715137057554im, -97.97084385529092 - 6.604863938624451im, -8.44841743829018 + 12.029192871918498im, -5.77960655379471 + 99.30600295285531im, -0.6308385482293498 + 1.0300087823688875im, -2.7230351076434256 + 0.36416309734736974im, 1.2115952535659582 + 2.557001213226485im, 1.8856180831641267 + 1.0905465168761456e-39im, -1.3333333333333333 + 0.0im] [-0.4714045207910324 - 8.000515778235231e-17im, -3.4828272306979056 - 0.17409481449556588im, 0.18840412359837122 - 3.2183062083132628im, 2.7748497845863307 - 1.5591827634778204im, 0.6071119138625729 - 2.700339982331854im, 3.226087811542442 + 1.8492697281131592im, -1.2940620280850224 + 0.05472447712024644im, -1.1177277458589017 - 0.3279321582237617im, 0.5841972966609063 - 2.185291613411026im, -2.4501279303525574 - 0.6368336128738487im, -3.44658889234102 - 0.07775107064513871im, 0.689628807959021 - 4.242074354766066im, -0.2884319993117851 + 1.1444489581154829im, -2.6019761113122786 + 0.40462380950266863im, -1.3762121363597688 - 2.180922799767912im, 1.885618083164127 + 0.0im, -1.333333333333333 + 6.41463530422127e-50im] [-0.4714045207910317 - 1.5844894370167283e-18im, -0.2281762332296401 - 0.29041952978663477im, -1.3462836615356868 + 0.04922204454850766im, -1.4299393669237874 - 0.23173489241667958im, 0.8036739058310036 - 0.547556501756237im, -1.7321003987930235 - 0.06275041974984558im, -5.171412095891836 + 1.7377384819681332im, -2.0634262973842956 - 1.8458622088135248im, -2.657929435232866 - 4.001229578031089im, -0.3154662054680074 - 0.19931608509533238im, -1.103805370679455 - 0.30726003345968017im, -0.8663801072309276 + 0.42497136166574195im, 0.4893914027264445 - 0.2103391797342636im, -2.326974010238867 - 0.07436613016965689im, -0.3640382408007303 + 1.0097136657909083im, 1.8856180831641267 - 1.0691058840368783e-50im, -1.3333333333333333 + 0.0im] [-0.47140452079103146 + 2.436994584855907e-16im, -1.6385662177004199 + 1.5502741806014477im, 1.8428817549284473 + 1.378399288892716im, -1.1537281946857392 + 0.2342966677688942im, -3.6537637854207725 + 0.31163621376081824im, 0.45938663080061787 + 3.0670456846671477im, -2.4916749997466603 + 0.677485982757164im, -4.990034031981882 + 0.39951773376438554im, 1.0085831036999335 + 4.360566716728224im, -56.73140692891447 - 20.23924261862209im, -5.470215988739186 + 5.237539348803383im, -19.949053566698844 + 58.38357700620286im, -0.562387032231428 + 0.6533161046913081im, -2.69883384207111 + 0.2309821239428025im, 0.7823840218082853 + 2.4472986674528894im, 1.885618083164127 + 0.0im, -1.333333333333333 + 1.4693679385278594e-39im] [-0.4714045207910311 + 7.496456561169498e-17im, -0.6980725035107491 - 1.6519165976846781im, -2.0800590998515216 + 0.5543869186308296im, -0.2522156843308437 - 2.1500743913307323im, -6.195235751179262 - 1.413271738509281im, -1.7139433814264262 + 5.424819854187695im, -1.8110810596939138 - 2.1424622260686528im, -6.171186965774296 - 0.810530625199712im, -1.7038164769001198 + 5.165229095401977im, -2.3368772754178972 - 1.5657022983970612im, -4.703657583790407 - 0.6146891177275858im, -1.7669427414134398 + 4.914065478390324im, -2.207818143155665 + 0.09274323130982574im, -3.2805815903260296 + 0.0327896838841651im, 0.10297283743868216 + 4.306846044176117im, 1.8856180831641265 + 0.0im, -1.3333333333333335 + 1.0947644252537633e-47im]
In [3]:
tracker = pathtracker(F; parameters=p, generic_parameters=p₀) # we compute 100 random intersections data = [randn(n*N+n) for _ in 1:100] Ω = map(data) do pp # We want to store all solutions. Create an empty array. S_p = similar(S_p₀, 0) for s in S_p₀ result = track(tracker, s; target_parameters=pp, details=:minimal) # check that the tracking was successfull and that we have a real solution if is_success(result) && is_real(result) # only store the solutions push!(S_p, solution(result)) end end # return an array of type Array{Float64} # (and not Array{ComplexF64}) real.(S_p) end Ω = vcat(Ω...)
794-element Array{Array{Float64,1},1}: [-0.47140452079103135, -1.0450657970165176, 0.8280188751979082, -1.4072716179482827, -1.8276293465988476, 0.1126538863121203, -0.8376968482498709, -2.2386216369390524, -1.114810947808969, 0.40168704888186707, -2.8742312373669674, -0.870009004649992, 1.4568131830371633, -1.9849387596762313, -1.1796341492122016, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, -0.8787951153546268, 1.0027446948284624, -1.5699566040480526, -1.616862376833217, 0.5043070980270642, -1.1150400951914357, -2.85830851549161, 0.0024480991241107356, 0.2768074075497607, -2.9749202829205923, 0.2241736610473671, 0.9710783993831666, -2.1566719393661917, -0.6969438331786075, 1.8856180831641267, -1.3333333333333335] [-0.4714045207910314, -0.7946734805177347, -1.0706408534796377, 0.25094213821647227, -0.47990298318034214, -2.245006570889111, 1.4959527579877956, 0.09154072488973561, -1.89372229118997, 2.531459755327646, -0.8340187087968385, -2.1603024727001405, 2.9181574245664224, -1.4682755482596062, -0.9568976471322852, 1.8856180831641267, -1.3333333333333335] [-0.4714045207910314, 0.22491375687705265, -1.3142266089777774, 0.6202302366925454, 0.5252167849702263, -2.1616648943837666, 0.9491844424156477, -0.616209142092952, -2.9290865409152205, 0.9936064774743825, -1.7526266571341305, -2.0885022713093266, 2.1837074621911103, -1.7279428226784994, -1.3249249310923448, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, 0.8319701428006202, 1.0419229622510935, 0.3561126482579101, 1.9742405825678833, 1.1440678464261183, 1.1230109530852335, 1.8962696774494996, 2.3297269576414785, 2.46635599004982, 2.2347439726298255, 2.045369325134814, 2.92451675144471, 1.466027186679896, 0.9503062129276387, 1.885618083164127, 1.3333333333333333] [-0.4714045207910314, 1.1949776319759993, 0.5914441958924033, -0.571487547699182, 1.0205465369240714, 1.9912860372458785, 0.7241895874044881, 0.9006878404637402, 2.545230668461288, 1.5022793490237236, 2.0207872416435193, 2.171126866903456, 2.49259238038451, 1.6187355125480976, 1.2450412838991667, 1.885618083164127, 1.3333333333333333] [-0.47140452079103135, 1.2934616226030926, 0.3236275770554064, -0.5028316219603334, 1.4457254616521438, 1.729269089187906, 0.29355542323933015, 0.4432506621221405, 2.329945333553728, 1.6573301069319735, 0.8057795188620372, 2.2367174399279732, 1.8016813638520128, 1.8630094450414072, 1.3085862003845734, 1.885618083164127, 1.3333333333333333] [-0.47140452079103135, 1.243238684038707, 0.48180426761028405, 0.5974664799376856, 1.9553588650498466, 1.073749899909276, 1.0058543230680994, 1.295692968968926, 2.256145889047875, 2.409522476897586, 1.1241219866638648, 2.2394392449863108, 2.9116310150295974, 1.4705829824797507, 0.9635662911569731, 1.8856180831641267, 1.3333333333333335] [-0.4714045207910314, 1.105516622134786, -0.7453930345538993, -0.04617544013807781, 0.9841578321316546, -2.0886920604807475, 1.1976198680990766, 0.31242883273450944, -2.1305654718076577, 2.238923877543447, 1.2574522711091476, -2.2809538385042036, 2.8459299601484576, 1.4938118131985325, -1.0256937927193406, 1.8856180831641267, 1.3333333333333335] [-0.4714045207910314, -0.36145578243137416, -1.2834046497986131, 0.17940674679681626, 0.4238418331552316, -2.263074159855291, 1.5573080600224904, 0.1060482378370949, -2.282953842592591, 2.3165071899826963, 1.2991158548857844, -2.268589225736365, 2.8875430848502717, 1.479099351867025, -0.9873695148408486, 1.885618083164127, 1.3333333333333333] [-0.47140452079103135, 0.5688017280450942, 1.205919720358985, 0.5977128843453564, 0.6779325040459827, 2.1252012048695135, 1.8268372586051689, 0.5826892079122182, 1.4322495563816835, 2.6120256632155607, -0.44511280121441993, 2.004178047804024, 2.436053346594702, -1.6387250796453514, 1.2663952392742992, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, 1.01949229960036, 0.8593097397524063, 0.4316252259992146, 1.1841663907997846, 1.9351441694392368, 1.627661339317607, 0.48210822114837515, 1.6583555460026036, 1.557007062856779, -0.8114597072614212, 2.225532756235336, 2.121345375684943, -1.7499911498072265, 1.3307249556283274, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, -0.3319457266763361, -1.2913519320150868, -1.1636789711744073, 0.7730066623061634, -1.8389250352883042, -0.2399382336337838, 1.6519958612844385, -2.4505466813142074, 0.43716421875665873, 2.392379002822633, -1.4538696660816486, 1.7467379744631204, 1.8824348666505366, -1.2958394273658649, 1.885618083164127, 1.3333333333333333] ⋮ [-0.47140452079103135, -1.2853862909988014, -0.3543442686006406, -1.154243984951937, -1.8565385995716481, 0.7445257449115834, -0.35991563623008005, -2.879022773747076, 1.3133566406772785, 0.6575314149834368, -3.2472149558150063, 0.40273267051122896, 0.8805576408434317, -2.18867586046699, -0.5081758244532483, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, -1.331970902557534, 0.06026020675244135, -0.24866558258536722, -1.8526866816721754, 1.356116079443554, 0.1639434382464032, -3.2017746379204057, 1.257548933628023, 0.849603921829774, -3.396995004067007, 0.03617318886566478, 0.9463332722875073, -2.1654206629515245, -0.6522075742778064, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, 0.9320244950983979, 0.9534716137957935, -0.24176879652005476, 0.4310655026500103, 2.255895324430562, 0.12209530444594109, -0.9333608168502115, 2.178799704040771, -0.23418087515015426, -1.4452596279691334, 0.9095373627466455, 0.8401672166594262, -2.2029560318847454, 0.38831539743967297, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, 0.3679173693238242, 1.2815672386291774, 0.6244321855761877, 0.5092826715975187, 2.1642663744004276, 1.35218173878464, -0.7024428590980487, 2.2101120510280303, 0.5163116058573611, -1.7698625448089045, 1.8076989107889583, 0.880053542638232, -2.188854086096631, 0.506876904611235, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, 0.8992220279562192, 0.9844681417984447, -0.36940639328957986, 0.2974265106095656, 2.2601791346521045, -0.2974969423649234, -1.1074046953571175, 2.1143082547277396, -0.2995808043087642, -1.4393209965358302, 0.7395983847801785, 0.8547910717990976, -2.1977857183165703, 0.4360249382054165, 1.8856180831641267, -1.3333333333333335] [-0.4714045207910314, 0.8613176413096886, 1.0177964917145728, 0.12683490797560132, 0.5073924416390924, 2.2493997309548326, 0.8146520248827888, -0.7197007799260432, 2.1039698878056985, 0.027345694779926544, -1.6140083353630406, 1.342154464708827, 0.8267112507634773, -2.2077134342509668, 0.33789903730921056, 1.8856180831641267, -1.3333333333333335] [-0.4714045207910314, 0.8712797093877704, 1.0092816483950058, -0.43554722286892456, 0.2089773317170862, 2.258309196016548, -0.5722910285252211, -1.184177076602339, 2.0572571475445525, 0.7087823260572257, -1.7712678186017947, 1.9381961512552355, 0.9198157188404517, -2.1747960338829686, 0.599304861193794, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, 0.469041544066437, 1.2481096937839842, 0.5205290772709177, 0.2621468369827796, 2.2346502744073273, 0.39629547925267644, -1.0444505583051868, 2.761308854276814, 1.3818037363130589, -1.8800986613869521, 2.1864473726295777, 1.059946716920792, -2.1252522443844453, 0.831343029853193, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, -0.8786811225498685, 1.0028445854928274, -0.07185062875982146, -0.40213126979484587, 2.272985099452554, -0.30997838203832173, 0.9897303041854314, 2.3505514065431945, -0.14735821610210365, 1.5678791324987185, 1.0702004335866186, 1.1618566113395445, 2.089221655677693, 0.9512108998774896, 1.8856180831641267, 1.3333333333333333] [-0.4714045207910314, -0.924192810319554, 0.9610647361813994, -0.8111061496177753, -0.23664128857047134, 2.1492884980684344, 0.2681040423276839, 0.5890630990015677, 2.541101751985818, 0.34378838053421523, 1.706979912189246, 1.6782379853676186, 1.685959470668116, 1.9039233127424469, 1.2785004942721274, 1.885618083164127, 1.3333333333333333] [-0.4714045207910314, -0.44933198582759326, 1.2553400114271869, 0.4497336631353765, -0.08227642507109022, 2.2636924604401742, 0.7239562680491822, 1.3019590142501025, 2.1704497047883162, -0.05397967596205814, 1.8678579001534423, 1.1338330360294633, 0.7866715253305094, 2.221869614936215, 0.05310121750928835, 1.8856180831641267, 1.3333333333333335] [-0.47140452079103135, -0.8400429977026833, 1.035425294161036, -0.024580865906231788, -0.3464959763419161, 2.283127165258978, 0.9988763672529918, 0.6067800831313921, 2.0738425592099214, 0.42189699558027854, 1.8459559727803165, 1.71116099202328, 0.8464829524921471, 2.2007230820669967, 0.40967450981856396, 1.8856180831641267, 1.3333333333333335]
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
using JuMP using Ipopt m = Model(with_optimizer(Ipopt.Optimizer, print_level=0)) @variable(m, 0 <= x <= 2 ) @variable(m, 0 <= y <= 30 ) @objective(m, Min, x*x+ 2x*y + y*y ) @constraint(m, x + y >= 1 ) optimize!(m) println(termination_status(m)) println("| x = ", JuMP.value(x), "| y = ", JuMP.value(y))
In [ ]:
In [ ]: