CoCalc Shared Filesjulia-1.3.ipynbOpen in CoCalc with one click!
Author: Harald Schilly
Views : 34
In [1]:
VERSION
v"1.3.1"
In [2]:
println("Hello 1.3")
Hello 1.3
In [3]:
using Pkg
In [3]:
for i = 1:10 println(i) end
1 2 3 4 5 6 7 8 9 10
In [5]:
# Import libraries. using Turing, StatsPlots, Random # 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])
Sampling 0%| | ETA: 0:20:55 iterations: 1 n_steps: 10 is_accept: true acceptance_rate: 1.0 log_density: -81.18342565332651 hamiltonian_energy: 89.1460132575264 hamiltonian_energy_error: -0.10029374074821362 step_size: 0.05 nom_step_size: 0.05 4m mass_matrix: UnitEuclideanMetric([1.0]) Sampling 100%|███████████████████████████████| Time: 0:00:02 iterations: 1000 n_steps: 10 is_accept: true acceptance_rate: 1.0 log_density: -71.18884958369689 hamiltonian_energy: 71.84314139644643 hamiltonian_energy_error: -0.009602725274447721 step_size: 0.05 nom_step_size: 0.05 mass_matrix: UnitEuclideanMetric([1.0])
In [6]:
using Compat
In [6]:
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="--")
WARNING: both PyPlot and StatsPlots export "plot"; uses of it in module Main must be qualified
UndefVarError: plot not defined Stacktrace: [1] top-level scope at In[6]:4
In [ ]:
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)
In [ ]:
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
In [4]:
using SpecialMatrices
In [3]:
using ApproxFun
In [1]:
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]
15-element Array{Polynomial{true,Float64},1}: z₁₋₁² + z₂₋₁² + z₃₋₁² - 2.0 z₁₋₁² - 2.0z₁₋₁z₁₋₂ + z₂₋₁² - 2.0z₂₋₁z₂₋₂ + z₃₋₁² - 2.0z₃₋₁z₃₋₂ + z₁₋₂² + z₂₋₂² + z₃₋₂² - 2.0 z₁₋₂² - 2.0z₁₋₂z₁₋₃ + z₂₋₂² - 2.0z₂₋₂z₂₋₃ + z₃₋₂² - 2.0z₃₋₂z₃₋₃ + z₁₋₃² + z₂₋₃² + z₃₋₃² - 2.0 z₁₋₃² - 2.0z₁₋₃z₁₋₄ + z₂₋₃² - 2.0z₂₋₃z₂₋₄ + z₃₋₃² - 2.0z₃₋₃z₃₋₄ + z₁₋₄² + z₂₋₄² + z₃₋₄² - 2.0 z₁₋₄² - 2.0z₁₋₄z₁₋₅ + z₂₋₄² - 2.0z₂₋₄z₂₋₅ + z₃₋₄² - 2.0z₃₋₄z₃₋₅ + z₁₋₅² + z₂₋₅² + z₃₋₅² - 2.0 z₁₋₅² - 2.0z₁₋₅z₁₋₆ + z₂₋₅² - 2.0z₂₋₅z₂₋₆ + z₃₋₅² + z₁₋₆² + z₂₋₆² - 2.0 z₁₋₆² + z₂₋₆² - 2.8284271247461903z₁₋₆ + 4.440892098500626e-16 z₁₋₂² + z₂₋₂² + z₃₋₂² - 5.333333333333333 z₁₋₁² - 2.0z₁₋₁z₁₋₃ + z₂₋₁² - 2.0z₂₋₁z₂₋₃ + z₃₋₁² - 2.0z₃₋₁z₃₋₃ + z₁₋₃² + z₂₋₃² + z₃₋₃² - 5.333333333333333 z₁₋₂² - 2.0z₁₋₂z₁₋₄ + z₂₋₂² - 2.0z₂₋₂z₂₋₄ + z₃₋₂² - 2.0z₃₋₂z₃₋₄ + z₁₋₄² + z₂₋₄² + z₃₋₄² - 5.333333333333333 z₁₋₃² - 2.0z₁₋₃z₁₋₅ + z₂₋₃² - 2.0z₂₋₃z₂₋₅ + z₃₋₃² - 2.0z₃₋₃z₃₋₅ + z₁₋₅² + z₂₋₅² + z₃₋₅² - 5.333333333333333 z₁₋₄² - 2.0z₁₋₄z₁₋₆ + z₂₋₄² - 2.0z₂₋₄z₂₋₆ + z₃₋₄² + z₁₋₆² + z₂₋₆² - 5.333333333333333 z₁₋₅² + z₂₋₅² + z₃₋₅² - 2.8284271247461903z₁₋₅ - 3.3333333333333326 z₁₋₆² + z₂₋₆² - 5.333333333333333 z₁₋₁² + z₂₋₁² + z₃₋₁² - 2.8284271247461903z₁₋₁ - 3.3333333333333326
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:25 # 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.47140452079103173 + 4.011039307809565e-18im, 1.7656329963376112 - 0.28196943336128727im, -0.4158726598843144 - 1.1971321597332196im, 0.0016128323410529483 + 0.6779361902526857im, 1.9548213811478752 - 1.2575409873050183im, -2.192855084444861 - 1.1205367056268116im, 2.3785708464561783 + 0.2712573940824863im, 1.5206005023417013 + 0.7202337737127787im, -0.7969352055649576 + 0.18716694281038934im, -7.475876431983659 + 0.5792929222650958im, 0.9007134911497243 - 7.426547855847295im, -0.4239227070079064 - 5.213628608579645im, 2.000618398751079 - 1.5686854270032025im, 1.79267458183827 + 0.5546140514912391im, 2.131986791926081 - 0.03487722905692533im, 1.8856180831641265 + 1.2163270670339412e-42im, 1.3333333333333335 + 7.174648137343064e-43im] [-0.47140452079103384 + 3.968267807890771e-16im, 0.7781929928542766 - 8.319633290471327im, 8.424905720603878 + 0.7684691727681308im, 3.763349777991325 - 0.6927554133974069im, 2.6799465478144078 + 7.7527717673157905im, -7.1443641771021795 + 2.543254032435036im, 3.8314788002125817 - 0.48484048898604526im, 2.2281670765338357 + 1.8729835758694293im, -1.0944681996010595 + 2.101836088918296im, 2.5990024712504245 - 0.4085424331599185im, 0.772172702476715 - 0.23177637948801066im, 1.069247968143296 + 0.7289743659843204im, 3.273726452379517 + 0.45609661825479214im, -1.342562912886332 + 0.16125450582210774im, 0.8964194480291614 - 0.7046067809764898im, 1.885618083164127 - 5.473822126268817e-48im, -1.333333333333333 + 1.642146637880645e-47im] [-0.47140452079103173 - 8.54709573122182e-17im, 0.977546865513525 + 1.0994307247180652im, -1.5792590525590273 + 0.6805375324940476im, 0.2865830602353856 + 1.55494354855081im, 3.105956336333442 + 0.1649530445084206im, -0.6259071667057681 + 1.5305104101415528im, 8.27833523316048 - 5.615282223707549im, -2.8452237489230843 - 8.405879625977605im, 4.755141190666713 + 2.7005609792877356im, 0.5119517691126851 + 1.22694886466924im, 3.5925030784660974 - 0.6061107249775305im, 1.7788399470615814 + 1.717256991881444im, 0.17692941250567448 + 0.3950496528646285im, 2.437446006312943 - 0.13967114422298518im, 0.5508043830409031 + 1.5054882860689343im, 1.8856180831641267 + 2.5633448340446722e-39im, 1.333333333333333 + 0.0im] [-0.47140452079103184 + 5.435674716670842e-19im, 2.1268631103288564 + 0.18752732750240356im, 0.23972619136029127 - 1.6637521030982587im, 1.0809511320101677 + 1.3317664309713027im, 2.1306774740436936 - 1.2820559962782345im, -1.8753765107978166 - 0.6889674650192986im, 0.7055735913246728 + 1.0450846715108832im, 4.197226356541995 - 0.8506470919373244im, -1.2480591130968612 - 2.281688289681429im, 1.1569103593448176 - 0.22709106558319256im, 4.188100489748473 + 0.8622665705196096im, 1.2823649975002274 - 2.0486002847987628im, 3.521449526745965 - 1.2878611152133954im, 1.2549795800158858 + 0.4553276638969306im, 1.6776703882156296 + 1.2770090917362449im, 1.8856180831641265 + 0.0im, 1.3333333333333335 + 0.0im] [-0.47140452079103734 + 8.91039866752335e-17im, -19.02613989218612 + 0.04628598737856691im, 0.046400063906963065 + 18.97936331894622im, 0.6905950265781474 + 0.12295486319470407im, -39.585555838514 - 5.421712155445003im, -5.432111470473698 + 39.525404155230085im, -7.1349082303969205 + 1.6552030618707052im, 20.673044625979834 - 5.563543489885482im, -5.77028547730352 - 21.204192353832482im, -4.464654292046032 + 1.1645876882964734im, 11.428767663523885 - 3.7648901234641436im, -3.8864210842312352 - 11.682637841672634im, -0.16208874147427263 - 0.09287072965219119im, 2.5573070241252256 + 0.032834761355403475im, 0.11982582991339646 - 1.922464556488998im, 1.8856180831641267 + 4.591774807899561e-41im, 1.3333333333333333 - 2.2958874039497803e-41im] [-0.4714045207910313 - 1.0901403372342142e-17im, 2.6585553783526676 - 0.21523275789225021im, 0.2484218599112077 + 2.3033730054860757im, 1.7666662903377017 - 0.09477028482479388im, 1.5125458759670813 + 0.11650728397720178im, -0.037696014924286377 + 0.23331761704364404im, 1.9964927368287095 + 0.1662559514001257im, -0.12697829381769862 + 0.07992921082001371im, 0.1064931570984202 - 0.5986544766650996im, 1.258392268134596 + 1.8312259810169054im, -0.5427974509546325 - 0.918242757921168im, 2.3821636873234673 - 0.2410209257214835im, -2.556927539537022 + 6.4682265540384165im, 3.404010401104629 - 2.286863429305732im, 6.946817241751713 + 4.818141324246341im, 1.885618083164127 + 3.779860102044577e-51im, 1.333333333333333 + 5.345529420184391e-51im] [-0.4714045207910317 + 7.053197973133923e-18im, 0.25370298669556623 - 0.46735861048602056im, 1.3925110112544707 + 0.08514853698095849im, 0.5960806505131917 - 0.36656171448340374im, 1.1705387984002715 - 0.08927945860043611im, 1.9436603548050537 + 0.16618408386833428im, -0.2667210382173707 - 0.19203924496697608im, 2.904530829342215 - 0.4684867923009158im, 1.3600664183306133 - 1.2185471918086008im, 1.6992476869903672 - 0.30470109372882137im, 3.1440440773630485 - 0.1335360956326688im, 1.4651096369945764 + 0.1262758600813978im, 2.1275534934861393 + 0.04188078569542663im, 1.747796248709411 - 0.014807093783328359im, 1.3310409496922064 - 0.0030017512346783726im, 1.885618083164127 - 1.3684555315672042e-48im, 1.333333333333333 + 4.1053665947016125e-48im] [-0.47140452079103146 + 4.124711938146536e-18im, 2.53563254072302 - 0.1570876262599644im, 0.18449642267886154 + 2.158938862370356im, 2.16054850685737 - 0.03634722011711445im, 0.9845348153213832 + 0.08527953118392516im, 0.009991152644237647 - 0.5435544351876425im, 1.6743926510244336 + 1.2976516166647296im, 3.1989541704289044 - 1.8038960675367164im, 2.471860861443278 + 1.4191645258969365im, -0.2299773484751138 + 1.2117750117309314im, 3.7026502327103836 - 0.3909577054731006im, 1.5027772583814922 + 2.3223191314928004im, -0.2732726620335525 - 0.17360652852200897im, 2.596616476218413 + 0.061379176788084175im, -0.21888326496934757 + 2.0665664282555243im, 1.885618083164127 - 5.345529420184391e-51im, 1.333333333333333 - 3.207317652110635e-50im] [-0.4714045207910316 - 1.963761571861415e-19im, -0.12163443898434803 + 0.563002649709222im, 1.4429854610560902 + 0.04745752004594918im, -3.2340166066456724 + 2.714308044009984im, 2.7173733632223933 + 3.2116019488317527im, 2.274359230219067 + 0.022422007998612305im, 4.416296864235485 - 2.307301230118734im, -2.185600913683489 - 4.491300525667862im, 4.296260241909321 + 0.3437791771308576im, 0.5976221655847549 + 0.3416492155120285im, 0.02543271409318352 - 0.19661934643779688im, 1.461111281427037 + 0.12516789938441944im, 0.6995023803244015 + 1.8002098829595392im, 2.252688561708242 - 0.6364703078998646im, 2.214299960756595 + 1.2285596188734875im, 1.8856180831641265 - 3.096461395594918e-47im, 1.3333333333333335 + 4.3790577010150533e-47im] [-0.47140452079103157 + 4.058367893078921e-17im, 1.6229539473774257 - 0.4922645313851643im, 0.7408892623263645 + 1.0783293873862658im, 3.2081223298023995 - 3.272149468319395im, 2.1875948244967987 + 2.522266771099775im, -3.1374644465149917 - 1.5871918634296427im, 0.028386753712611144 - 1.29415615025903im, 4.363612379192261 - 0.04913486137753352im, 0.145954724860976 + 2.032483296768397im, 0.09260828190082449 - 0.10110557063008638im, 2.2181583917031196 - 1.1268509338173265im, 1.6879365325461162 + 0.48330174059113357im, 1.8831064576727312 + 0.040148939746494985im, 1.8342213270417167 - 0.014194793776098365im, 1.323233930592453 + 0.005449407477712925im, 1.885618083164127 - 1.0691058840368783e-50im, 1.333333333333333 + 3.207317652110635e-50im] [-0.4714045207910296 + 6.062858301440297e-16im, -1.7649786284232443 - 4.685443491440577im, 4.850078511531284 - 1.7050667545722815im, 1.981134539054662 - 0.006034875876457388im, -0.45362625663729045 - 0.6725139938796361im, 1.3058920571249155 - 0.22445507876614457im, 4.2261069269765645 - 1.7920939681202093im, 2.8657227944859978 + 0.8962410804314238im, 0.8969037366981353 + 2.703727126597294im, 5.025856282296089 - 1.6849541513269206im, 2.220708880239453 + 0.5933543963725411im, 1.954361228896933 + 2.4379470577615576im, 4.478377559136946 - 1.8868073306113846im, 0.916654429610302 + 0.6670871291338992im, 2.177996480620102 + 2.373740621454513im, 1.885618083164127 + 1.0691058840368783e-50im, 1.333333333333333 - 4.276423536147513e-50im] [-0.4714045207910315 + 3.74268521164946e-17im, -3.3048373166079177 + 0.3037857822871625im, -0.33168416987064425 - 3.0268631449884547im, -11.351305205869625 - 0.44293206487080405im, -20.732928785904814 + 1.6652971268618795im, -1.2555676005139866 - 23.49425843157228im, 3.0335906651987767 - 0.914301647438097im, -2.5021124772626657 - 1.2538937692989771im, 1.3377982027341517 - 0.3583648045953449im, 1.219278550853488 - 5.3645328733598685im, -7.946589259832875 - 6.815414180527884im, 8.374233409207097 - 5.809090357254653im, 0.3281041895203749 - 0.7562395252849325im, -2.3839976513272143 - 0.26737104826513575im, 1.0399159902802362 - 1.4027775332481685im, 1.885618083164127 + 0.0im, -1.333333333333333 + 6.41463530422127e-50im] [-0.47140452079103173 - 4.916221512867805e-18im, -2.2765447900214215 + 0.019812426361386536im, 0.02444274590707047 + 1.8452867849700363im, -14.843756876659242 - 9.758067671476674im, -15.404528125648365 - 8.244226739678142im, -12.780162692224911 + 21.270840859668006im, -4.271752526821735 - 4.9176633031368695im, -8.335647810054379 - 4.120206078260779im, -6.423964168121798 + 8.633572812255796im, 16.13023156174157 - 8.442125937833843im, 3.885848890279811 - 3.9448796965786532im, -9.37240450463596 - 15.0275062113383im, 9.102480619224425 + 0.40980402965590285im, 0.7182128857363562 + 0.14488760416363072im, 0.44169688449501526 - 7.368725203899242im, 1.8856180831641267 + 0.0im, -1.3333333333333333 + 0.0im] ⋮ [-0.4714045207910313 + 2.273476722364968e-18im, -0.77706581663088 - 1.0292011354742838im, -1.5779944884779298 + 0.5068186401501104im, -6.709444665123701 + 3.386744605355646im, 7.874652762579575 + 5.7100875923242285im, 2.7544110360135026 - 8.074968193969434im, -1.9591368928206105 + 0.9276833575296504im, 0.005701593562819509 - 2.332024086448638im, -4.031910982098865 - 0.4711901533454467im, -1.0217833326405006 - 1.4206402724407665im, -4.70135613482884 - 0.5540535424988019im, -1.5692996779956934 + 3.8210907629110826im, -0.3035857316449227 - 0.745226784457385im, -2.6073337647588017 - 0.26347745640583087im, -0.9144786233822236 + 2.1510876933223897im, 1.8856180831641265 + 0.0im, -1.3333333333333335 + 4.6773382426613424e-51im] [-0.47140452079102924 + 1.863494071053323e-15im, 9.225957545993822 + 5.442979074693783im, 5.485466575625888 - 9.154498195283944im, -6.994852706513919 - 1.424021352741923im, 37.94407701692341 + 32.41383640615574im, 32.29709055183091 - 38.38964759481103im, 12.947600544897641 + 3.39081436097143im, -27.68611643640249 - 38.83502029843967im, -38.23299223071479 + 29.27078461675888im, 5.697235017864991 - 0.38027571837807506im, -2.299703270691553 - 0.21076037371162737im, 0.39212166749403815 + 3.177056975315061im, 4.078510664360417 - 0.28356770366635825im, -1.058028726044549 - 0.10025632309398971im, 0.37890748462364593 + 1.713965988134258im, 1.8856180831641267 + 5.605193857299268e-45im, -1.3333333333333333 + 0.0im] [-0.4714045207910298 - 1.7207790513961902e-15im, 4.726187355144255 + 6.043876665380994im, -6.135485399321392 + 4.6556208046936955im, 1.4057391477030112 - 0.30747044786787975im, 1.4683502717424888 + 4.47639822119487im, -4.793236722042905 + 1.2811170520641892im, -7.7670569925124715 + 4.822779345825449im, 11.041222352640512 + 6.122366804571688im, -2.2478499253754816 + 13.578693533984675im, -5.099259645420227 - 1.892412696822426im, 2.9200956465712995 + 9.11119162179275im, -8.123047188621731 + 6.398101177809494im, 3.2878815700653474 - 0.4601759528005153im, -1.3375583230342591 - 0.16269676838211258im, -0.8914671314758154 - 0.7230783067954772im, 1.885618083164127 - 4.05859388043417e-42im, -1.3333333333333333 - 1.1479437019748901e-41im] [-0.4714045207910316 - 2.2249903122545596e-15im, 7.549288798019353 + 3.3857234489378145im, -3.430360100503124 + 7.4510556785303335im, -1.9710466691393984 + 1.2562487903366881im, -4.388263820841318 + 12.274508501154264im, -12.446769944109736 - 4.526468057256097im, 0.915541270738024 - 1.7312166432549863im, 1.3013271745409425 - 4.2334180091116im, 4.294055533132983 + 1.5990919909057004im, 2.237708533605532 - 0.6351087766071661im, 2.4238140981852845 + 0.7891087290691299im, -0.9271959836423184 + 2.9564214553732935im, -0.22382917105208125 + 1.2384333147912268im, -2.5791355623391454 + 0.4378522974681049im, -1.489483288798149 - 2.120122560170099im, 1.8856180831641265 + 2.597500083477869e-40im, -1.3333333333333335 + 0.0im] [-0.47140452079103146 - 6.0446817850165625e-18im, -0.6570021311926099 - 0.2618512800521933im, -1.1980452591174042 + 0.14359795486903632im, -5.722393151221144 + 0.1849502257633983im, -0.721529642015268 - 4.710574956054401im, -0.9147645455127705 + 2.5585398646935977im, -1.9489554996652416 - 0.625797536497986im, -1.0519891634662026 - 0.9880755353687448im, -3.261511459106559 + 0.7307153624663212im, 0.9904778084508126 + 2.022308806316321im, -4.015077578658683 + 0.8080993015750803im, -2.270023355634992 - 1.7521254581889383im, 0.8489806671877358 + 0.9868217524171479im, -2.199840006567637 + 0.34889417647827875im, -1.4507363245569949 - 0.9135329840387925im, 1.8856180831641267 + 0.0im, -1.3333333333333333 + 1.6704779438076223e-51im] [-0.47140452079102957 + 6.601666499348625e-18im, 0.0605075233188413 - 3.465289242010338im, -3.7128877295139255 - 0.0564725046628114im, -1.4934486425366005 - 0.9495612057028884im, -5.071749925548021 - 2.215737204701763im, -2.605351066573093 + 4.857612495689162im, -0.47162805984734113 + 0.3734821931266176im, -3.3044387393892563 + 0.30449365698067304im, 0.4748265554790227 + 2.9726740659368733im, -3.088770935337224 + 1.3730414185485478im, -5.356013149426567 + 0.4081976990155167im, 1.4207286717172212 + 5.963201114918514im, -17.243923983480578 - 3.858626607121123im, -8.596647791492204 - 1.3642305199810847im, -4.101074741543631 + 20.414793813029934im, 1.885618083164127 + 5.473822126268817e-48im, -1.333333333333333 + 0.0im] [-0.471404520791032 + 2.0870043222587566e-17im, 1.0141694132070902 + 0.9100674636075541im, 1.4152018444170922 - 0.6521773478368361im, -2.3577505969992365 + 3.6012403598533833im, -5.090474488581536 + 1.8692831108452321im, 3.715803174209833 + 4.8458876188739755im, 1.6185334957234545 - 1.6233179289782946im, 1.3950766324844723 - 0.19770945900225162im, -1.1957758188735965 - 2.1131603862840582im, -0.4381568714455566 - 1.2139831166781534im, -2.326634350377021 - 2.0880213766787654im, -2.799572079429752 + 1.7485019781725912im, 2.1997935626149117 - 0.7636111459359154im, -1.722255527332241 - 0.2699773097404583im, -1.5535648622275804 - 0.08683752673239523im, 1.885618083164127 - 1.3684555315672042e-48im, -1.333333333333333 - 2.7369110631344083e-48im] [-0.4714045207910318 - 1.239473229004493e-18im, -2.159809573803696 + 0.24955448890254384im, 0.31520036366059556 + 1.7099922349638572im, 1.3397170394314093 + 5.244198737070722im, -0.39412511408443646 + 4.290247300401563im, 7.061288067179608 - 0.7555063819437031im, 3.262096989461359 - 6.778404840814522im, -4.369748813286499 - 6.260506106411572im, -8.425455468975407 + 0.46061843986336415im, -1.523049280484506 + 0.14332420716601096im, -2.6982698289020175 + 1.1851002086988478im, 0.7779720466230914 + 2.7072066178839056im, 1.0904587409569648 + 0.8285043471080477im, -2.1144646148325923 + 0.292920521041317im, 1.391615516256409 + 0.6378215414185574im, 1.885618083164127 + 5.473822126268817e-48im, -1.333333333333333 - 1.642146637880645e-47im] [-0.4714045207910316 + 1.7399163917489335e-18im, 0.33741088783466694 - 0.39314105494367685im, -1.3520786915241636 - 0.09810824859851208im, -2.2229201876665403 + 0.3648476106837109im, 0.8513187215060288 + 0.8600059642783289im, -0.7424483218068092 - 0.10625378076383388im, -3.419385450780726 - 3.503660066821699im, -6.518081228425971 - 1.427916924027567im, -3.9810283113863827 + 6.529109231389277im, -1.5512501623596642 - 2.3042560852802723im, -4.72327551929385 - 0.882499336586971im, -2.546097709194821 + 4.285399676465513im, -5.39577774403717 - 7.802639381751186im, -4.407695516292062 - 2.7586496089947374im, -8.33238801018975 + 7.836312205998671im, 1.885618083164127 + 2.7369110631344083e-48im, -1.333333333333333 + 2.7369110631344083e-48im] [-0.4714045207910313 + 9.245219367224218e-18im, 0.8124297156534113 - 0.527091588895667im, -1.231455841906656 - 0.34773871308839904im, 2.8383176547555578 - 1.5412460502576157im, 0.9223195466625381 - 5.178903325642348im, -5.343755927776132 - 1.7124939398368786im, 1.4420828785806348 - 4.159025559064252im, -4.820862256382591 - 5.219873010330695im, -6.097391468330485 + 3.449591610522027im, 1.4643177775424585 + 3.064686077927306im, 1.763297895714036 + 2.535307551057355im, 3.7920076396354623 - 1.7298908599269531im, -2.0006576077975926 - 0.9265762205927253im, -3.2073392806530676 - 0.3275941644336589im, -1.0310153048422626 + 4.088051879126514im, 1.885618083164127 - 9.495567745759799e-66im, -1.333333333333333 + 7.032117859233588e-50im] [-0.4714045207910316 + 3.835360170999174e-19im, 1.1388739319471395 - 0.017444013079394576im, -0.6941666228452446 - 0.02861925524917728im, -2.3163677981939483 - 0.022796570912116416im, 0.9641785611114648 + 0.5989866166250725im, -0.6303613091699114 + 0.9999587343688855im, -0.11468868759992877 + 0.029854756235814933im, -1.6344872028060464 - 1.1794602919822874im, 0.9537309229482688 - 1.9907196651676982im, 0.35235122070930947 - 0.030433036070612082im, 0.3902477723766338 - 0.08980220267923968im, -0.34489907446444973 - 0.31348131109368116im, -1.9305294651955192 + 2.910152663843613im, -3.1825452380600936 + 1.0288943414459562im, -3.1898502976748264 - 4.0780019137164585im, 1.8856180831641265 + 3.870576744493646e-48im, -1.3333333333333335 - 5.473822126268817e-48im] [-0.47140452079103284 - 8.256851631492691e-17im, -4.3970097904609045 + 0.42749238900678005im, 0.44838168834722286 + 4.192160983957756im, -1.8795462292373641 + 0.010763267068487365im, -4.164604060594773 - 0.12353663077349669im, -0.12536360266516555 + 3.942540622725639im, -0.8497208494105755 - 2.4872933617109063im, -0.25065465479422633 + 0.6291729982120925im, -0.26092797408057083 + 6.697728321729612im, -3.204367909512877 - 0.9228017456579567im, -2.146390251189187 - 0.41059439084857113im, -1.087563018466142 + 4.625832695584389im, -2.6235092146797783 - 0.5809940136326244im, -3.4275505781027324 - 0.20541240343420913im, -0.639483968329619 + 4.7693989456575805im, 1.8856180831641267 - 1.0691058840368783e-50im, -1.3333333333333333 + 0.0im]
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(Ω...)
666-element Array{Array{Float64,1},1}: [-0.4714045207910314, -1.3209014207886487, 0.18165135379706746, -0.1351766551304241, -2.101082283456053, -0.9489540786509003, 0.5924634513854518, -3.241096397960265, -0.5355442406925583, 0.8050174466973178, -3.1836267328802923, 0.8614232022611277, 1.4715035952035411, -1.9797449146455959, 1.187712616084599, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, -1.23258847255258, -0.508432330903805, -0.8522895559378467, -2.0706345554393786, 0.5651622634190719, 0.11402739061809636, -3.0893666443960814, 0.7337341760519628, 0.7891243383459237, -3.3058954343982756, -0.48993219770714147, 1.2256143111875095, -2.0666799047200164, -1.0132116398917033, 1.8856180831641267, -1.3333333333333333] [-0.47140452079103135, -1.0530367971509271, -0.8178577392333556, -1.0221920965888158, -2.0708527995209516, -0.005033261460753582, -0.38554360365197626, -3.300376054402702, -0.29304586907756974, 0.8519297601033887, -3.3615478491917856, 0.3888028571940756, 1.150228783968765, -2.0933327134698647, 0.9389374424428084, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, 0.04487912830793557, 1.3325778182230477, -0.9731916802390848, -1.225778033981088, 1.6981459001676562, -1.070180301478284, -2.043020745452256, 0.5480556611440518, 0.12723808025505, -2.778731871021252, 0.3902001613946802, 0.9243493559203335, -2.173193151121658, -0.6087675422422417, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, -0.6526997640232025, -1.1626524828261597, -0.9938870314822722, -1.9195008537689084, -0.8130426645417334, 0.06679851794351885, -2.7860041779389753, -0.46073859922097793, 0.2891419483433477, -2.716079872883974, 0.9341355852561062, 1.470088387645409, -1.9802452660761676, 1.1869456699516834, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, -0.14295581243993105, 1.3256475449633727, -0.046294060080430834, -1.387557498734683, 1.845501119219317, -0.4280680919603898, -2.422995346892648, 0.9611273005294358, -0.30162424186839376, -1.9733581847380837, -0.3737278883144715, 1.0372343313543713, -2.133282285309915, -0.8002041513868637, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, -1.2983916659547048, 0.30324389450926187, -0.17219953647818892, -2.1708587153399517, -0.7687997730245532, 0.0942687086867447, -3.4645416836830396, -0.26344934833121403, 1.1111224074745667, -3.387661865429799, 0.716396582826779, 1.3105528592905638, -2.0366495930461115, 1.0838109738856105, 1.885618083164127, -1.3333333333333333] [-0.47140452079103135, -0.4464594459917578, -1.256364493633321, -0.1552238892320696, -1.815219576042502, -1.4192310482430557, -0.6097951063787538, -2.5411831802792215, -0.29391249162656813, -0.16850632100384644, -1.903018448714169, 0.8884622304006089, 1.230457649127203, -2.0649675261696485, 1.017583516742141, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, -1.242958662879439, -0.4825262066983882, -0.8770738388042563, -2.0483655457986716, 0.6068553414145812, -0.4532403541597958, -3.3803398137376988, 0.39189086332011436, 0.8289299646785809, -3.3765674468233646, -0.2047874777798098, 1.056050431386035, -2.1266297893459774, -0.8261345193133878, 1.8856180831641267, -1.3333333333333335] [-0.4714045207910314, -0.40055325653979335, -1.2717448118443986, -0.8701438519388072, -1.7564448521458185, -1.2210997058540642, -0.9079991491155649, -2.1866940675422013, 0.12554523217765634, 0.26342546569927666, -2.922938931139547, 0.4183043014349975, 1.222036952233596, -2.067944692107541, 1.0099535802366721, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, 0.4579076638011763, -1.2522373374124918, 0.2828616326198176, -0.1412503382286086, -2.2876562180702082, 1.579855301144007, -0.4435143668165123, -1.811795018948052, 2.4560475692930406, 0.6223744132219928, -2.121905028176839, 2.1283962233847284, 1.74749829869641, -1.3302353762010797, 1.8856180831641267, 1.3333333333333335] [-0.47140452079103135, 0.8521480547668512, -1.0254859679853496, -0.19759346650613047, 0.2702294927992875, -2.2850090101679825, 1.2015629730562383, 0.16242875452640557, -2.4603380107896067, 1.795620764120621, 1.4364271178203074, -2.3053428134441236, 1.3383713670280375, 2.026814265314282, -1.1043573826697137, 1.885618083164127, 1.3333333333333333] [-0.47140452079103135, -0.06344746934429814, -1.3318228847754428, 0.21598545938437883, 0.8877010729369439, -2.121006935343317, 1.295427518531817, 0.25867378806476005, -2.7836754164331197, 2.490148223087456, 0.4899932772937993, -2.0631660604849165, 2.354861713490186, 1.6674306568172585, -1.2915840637911642, 1.885618083164127, 1.3333333333333333] ⋮ [-0.47140452079103135, -1.288281956155288, 0.3436675417063455, -0.06928958872818046, -1.6009679038730558, 1.6629594273449753, 0.36376828864214666, -2.9461406928996254, 1.7174666975938775, 1.7724829521020629, -2.9929051615333164, 1.601984744776887, 2.26492938264981, -1.6992265373098292, 1.312343362602294, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, -0.5601323860687215, 1.2099708623990657, -0.26509150060396125, -1.9591212984387483, 1.193693246879007, 0.5384846337914245, -2.3299845091028817, 2.296746226207769, 1.814204722321274, -2.7312705471011776, 1.8368464855805073, 2.473986400029843, -1.6253137199878012, 1.2524257173651907, 1.8856180831641267, -1.3333333333333335] [-0.47140452079103135, 0.9805938705334996, -0.9034453159156388, -1.0444028424153915, 2.0519026395393323, -0.1795872878004052, -0.03308853785769244, 2.973554264147718, 0.1779062929163702, 0.8342771913387834, 3.1715491457701015, -0.921400178758751, 1.5133802595591686, 1.964939277975927, -1.209344009523337, 1.8856180831641267, 1.3333333333333335] [-0.4714045207910314, 1.325156743388351, -0.14743603097668276, 0.618517441577659, 2.1864930255931476, -0.41233209531891013, 0.7589884902889933, 2.352996764082934, -1.8096668403041132, 2.0827227232222385, 2.0339780844415114, -2.1917071033661073, 2.7830678355992537, 1.5160369304727996, -1.0775914520106544, 1.885618083164127, 1.3333333333333333] [-0.4714045207910314, 0.9579268876124118, -0.9274447993098973, -0.35006163759613196, 2.252373206480387, -0.37095164367624717, 0.10716052385985411, 3.150900920764479, -1.3627156487383998, 1.5208890229360044, 3.136029752849212, -1.3966358383712898, 1.979959994279117, 1.7999784307835793, -1.3316688615541108, 1.8856180831641267, 1.3333333333333335] [-0.47140452079103135, 1.325072596782, -0.14819038779618915, 0.6185118005297207, 2.18625072419065, -0.4136233273337886, 0.7586353149317651, 2.352328292575677, -1.811043679980385, 2.0803438852108234, 2.02645525144299, -2.194310188188214, 2.7826643722591813, 1.5161795763046628, -1.0779031527238712, 1.8856180831641267, 1.3333333333333335] [-0.47140452079103135, 1.3171123699167084, -0.20734701056482546, -1.4248808974196197, 1.6384614684414958, 0.7864424822798738, -0.7585771062100779, 2.0659326835836147, 1.9583245659575406, 0.6074977212248268, 2.2896741901809263, 1.6688780180868514, 0.8120391530594473, 2.2129008041413414, 0.2716419428801382, 1.8856180831641267, 1.3333333333333335] [-0.47140452079103135, 1.3171807792956227, -0.2069119919964867, -1.42547584675058, 1.6379136151869622, 0.7865055199102081, -0.7598954374589203, 2.065449469292498, 1.958775033384562, 0.6071700167568675, 2.285373004777821, 1.6710847790668026, 0.8124514685591495, 2.212755028598427, 0.27373508944664315, 1.8856180831641267, 1.3333333333333335] [-0.47140452079103135, 0.8421496304224819, -1.0337126185536558, -0.009873452528560882, 2.1608797191496887, -0.8147605093744182, -0.4634231493679045, 2.615977304139431, 0.4450723607450444, 0.1978904571756428, 1.9011055369401892, 1.470558913685549, 1.5936015865124977, 1.936576755833686, 1.2453207373577984, 1.885618083164127, 1.3333333333333333] [-0.4714045207910314, -0.8646479350515879, 1.014968830156278, 0.5974782035750417, -1.6581894531587893, 1.492233516249729, 0.3287028837664467, -3.020764697292029, 1.225496695512451, 0.7305971884198117, -3.3309161923266006, -0.09446050758733492, 1.0295800205017123, -2.135988492864527, -0.7892677176669097, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, -0.08300149569415323, 1.3307473574989024, -0.9144966963470768, -1.4002345489158006, 1.5925992382662315, 0.179276962685955, -2.1899173403783307, 2.016934331881453, 0.6114395197035063, -3.0096220594748093, 0.9486086803111962, 0.8009252903918576, -2.216830147970056, -0.20706260848994065, 1.885618083164127, -1.3333333333333333] [-0.4714045207910314, -0.4700941284779588, 1.2477136242537092, 0.47449254578800915, -1.3627614709636153, 1.8030727468912702, 0.26824099999498446, -2.657695689110449, 1.2733504889763927, -0.06969381467683221, -2.5584108886464954, -0.09630004653606347, 1.0590613312735961, -2.125565275481993, -0.8301641318098114, 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 [ ]: