# Define τ(y,x) on vectors τ(y::Vector, x::Vector) = minimum(y./x) # Example y = [10,5,6,9] x = [1,2,3,4] τ(y,x) all(y.≥2x), all(y.≥1.99x),all(y.≥2.01x) # check these by hand # Example A= [ 1 2 3;4 5 6; 7 8 9] y = [0, .1, .0] A * y # any one positive entry multiplies an entire positive column of A # An example n = 6 A = rand(n,n) x = rand(n) [τ(A^k*x, A^(k-1)*x) for k=1:7] # This sequence will be increasing, but to an eig limit. # Pkg.add("JuMP") using JuMP # Pkg.add("Ipopt") (On my mac, this worked with 0.6.2 but not 0.6.0) using Ipopt A = rand(7,7) n=size(A,1) m = Model(solver=IpoptSolver(print_level=2)) @variable(m, t); @objective(m, Max, t) @variable(m, x[1:n]>=0); @constraint(m, sum(x)==1) @variable(m, y[1:n]); @constraint(m, y .== A*x) @NLconstraint(m, [i=1:n], t <= y[i]/x[i]) # nonlinear constraint status = solve(m) x = getvalue.(x) t = getobjectivevalue(m) norm(A*x-t*x) # demonstrate we have found an eigenpair through optimization A = rand(5,5) eigvals(A) Λ,X=eig(A);x=X[:,2];λ=Λ[2] norm(A*x-λ*x) τ(A*abs.(x),abs.(x)) - abs(λ) # This is non-negative