nx = 2 
 
ny = 2 
 
ns = 1 
 
nv = 4 
 
ne = 4 
 
jumps_to_approximate = [2] 
 
eqns_to_approximate = [3] 
 
variables = OrderedDict("z" => 1, "k" => 2, "c" => 3, "ce" => 4) 
 
function nlsolve_static_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
  f[1] = x[1] - ((0.95)*x[1] + (0.01)*0.0)
  f[2] = x[2] - ((1.0 - (0.025))*x[2] + exp(x[1])*x[2]^(0.30) - x[3])
  f[3] = x[3]^(-(2.0)) - ((0.99)*x[4])
  f[4] = x[4] - (x[3]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(x[1])*x[2]^((0.30) - 1.0)))

end 
 
function static_equations(x::Array{T,1}) where {T<:Number} 
 
  f = Array{T,1}(undef,length(x)) 
 
  f[1] = x[1] - ((0.95)*x[1] + (0.01)*0.0)
  f[2] = x[2] - ((1.0 - (0.025))*x[2] + exp(x[1])*x[2]^(0.30) - x[3])
  f[3] = x[3]^(-(2.0)) - ((0.99)*x[4])
  f[4] = x[4] - (x[3]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(x[1])*x[2]^((0.30) - 1.0)))

  return f 
 
end 
 
function dynamic_equations(x::Array{T,1}) where {T<:Number} 
 
  f = Array{T,1}(undef,4) 
 
  f[1] = x[5] - ((0.95)*x[1] + (0.01)*x[9])
  f[2] = x[6] - ((1.0 - (0.025))*x[2] + exp(x[1])*x[2]^(0.30) - x[3])
  f[3] = x[3]^(-(2.0)) - ((0.99)*x[8])
  f[4] = x[4] - (x[3]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(x[1])*x[2]^((0.30) - 1.0)))

  return f 
 
end 

function dynamic_eqn_1(x::Array{T,1}) where {T<:Number} 
 
  f = x[5] - ((0.95)*x[1] + (0.01)*x[9])

  return f 
 
end 

function dynamic_eqn_2(x::Array{T,1}) where {T<:Number} 
 
  f = x[6] - ((1.0 - (0.025))*x[2] + exp(x[1])*x[2]^(0.30) - x[3])

  return f 
 
end 

function dynamic_eqn_3(x::Array{T,1}) where {T<:Number} 
 
  f = x[3]^(-(2.0)) - ((0.99)*x[8])

  return f 
 
end 

function dynamic_eqn_4(x::Array{T,1}) where {T<:Number} 
 
  f = x[4] - (x[3]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(x[1])*x[2]^((0.30) - 1.0)))

  return f 
 
end 

individual_equations = Array{Function}(undef,4) 
individual_equations[1] = dynamic_eqn_1
individual_equations[2] = dynamic_eqn_2
individual_equations[3] = dynamic_eqn_3
individual_equations[4] = dynamic_eqn_4

function closure_chebyshev_equations(state,scaled_weights,order,domain) 
 
  function chebyshev_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    approx2 = chebyshev_evaluate(scaled_weights[1],x[2+1:end],order,domain)

    #f = Array{T,1}(undef,4) 
 
    f[1] = x[3] - ((0.95)*state[1] + (0.01)*0.0)
    f[2] = x[4] - ((1.0 - (0.025))*state[2] + exp(state[1])*state[2]^(0.30) - x[1])
    f[3] = x[1]^(-(2.0)) - ((0.99)*approx2)
    f[4] = x[2] - (x[1]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(state[1])*state[2]^((0.30) - 1.0)))

    #return f 
 
  end 
 
  return chebyshev_equations 
 
end 

function closure_smolyak_equations(state,scaled_weights,order,domain) 
 
  function smolyak_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    poly = smolyak_polynomial(x[2+1:end],order,domain) 
    approx2 = smolyak_evaluate(scaled_weights[1],poly)

    #f = Array{T,1}(undef,4) 
 
    f[1] = x[3] - ((0.95)*state[1] + (0.01)*0.0)
    f[2] = x[4] - ((1.0 - (0.025))*state[2] + exp(state[1])*state[2]^(0.30) - x[1])
    f[3] = x[1]^(-(2.0)) - ((0.99)*approx2)
    f[4] = x[2] - (x[1]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(state[1])*state[2]^((0.30) - 1.0)))

    #return f 
 
  end 
 
  return smolyak_equations 
 
end 

function closure_hcross_equations(state,scaled_weights,order,domain) 
 
  function hcross_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    poly = hyperbolic_cross_polynomial(x[2+1:end],order,domain) 
    approx2 = hyperbolic_cross_evaluate(scaled_weights[1],poly)

    #f = Array{T,1}(undef,4) 
 
    f[1] = x[3] - ((0.95)*state[1] + (0.01)*0.0)
    f[2] = x[4] - ((1.0 - (0.025))*state[2] + exp(state[1])*state[2]^(0.30) - x[1])
    f[3] = x[1]^(-(2.0)) - ((0.99)*approx2)
    f[4] = x[2] - (x[1]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(state[1])*state[2]^((0.30) - 1.0)))

    #return f 
 
  end 
 
  return hcross_equations 
 
end 

function closure_piecewise_equations(variables,grid,state,integrals) 
 
  function piecewise_equations(f::Array{T,1},x::Array{T,1}) where {T<:Number} 
 
    approx2 = piecewise_linear_evaluate(variables[2],grid,x[2+1:end],integrals)

    #f = Array{T,1}(undef,4) 
 
    f[1] = x[3] - ((0.95)*state[1] + (0.01)*0.0)
    f[2] = x[4] - ((1.0 - (0.025))*state[2] + exp(state[1])*state[2]^(0.30) - x[1])
    f[3] = x[1]^(-(2.0)) - ((0.99)*approx2)
    f[4] = x[2] - (x[1]^(-(2.0))*(1.0 - (0.025) + (0.30)*exp(state[1])*state[2]^((0.30) - 1.0)))

    #return f 
 
  end 
 
  return piecewise_equations 
 
end 

unassigned_parameters = String[] 

solvers = "Any" 