Hi there,

I’m having trouble with the Roots package. I have an MVE below (base of post) which is setting up a simple economics model.

The last two lines showcase the issue. The first line works and returns the correct value of about 0.9. When I change the initial condition slightly, it fails with the following error message:

```
ERROR: MethodError: no method matching Roots.UnivariateZeroState(::Float64, ::Float64, ::Int64, ::Float64)
Closest candidates are:
Roots.UnivariateZeroState(::T, ::T, ::S, ::S) where {T, S} at C:\Users\nvonturk\.julia\packages\Roots\Ez3Om\src\state.jl:3
```

I’m making the transition over to Julia from Matlab and “fzero” in Matlab doesn’t exhibit this issue. I’m repeating this calculation for different parameter values so simply changing the initial guess would not be a robust approach.

Also, any feedback on how to ask for help is appreciated. First time posting.

Nick

MVE

```
# Load libraries
using Parameters, QuantEcon, Roots
# Define utility function
u(c;p) = (1/(1-p.σ)) * c^(1-p.σ) - p.ψ * (n^(1+p.ε)/(1+p.ε))
# Define production function
f(k,n,z;p) = exp(z)*k^(p.α)*n^(1-p.α)
# Define optimal labor choice as a function of k, k prime, z, and a choice for consumption
n_star(c, k, kp, z;p) = ((1-p.α)/p.ψ * exp(z) * k^p.α * c^(-p.σ))^(1/(p.ε + p.α))
# Taking the optimal choice of labor as given, return how much the resource constraint is violated for particular value of c
resource_constraint(c, k, kp, z;p) = c>0 ? (f(k,n_star(c, k, kp, z;p),z;p) - c - kp + (1-p.δ)*k) : -100
# Define model parameters
RBCModel = @with_kw (α = 0.333, δ = 0.025, β = 0.984, σ = 1, ψ = 0.8356, ε = 0.25, z0 = 1, ρ = 0.9, σ_z = 0.05, μ = 0, n_std = 1.2, u = u, f = f, Kn = 500, mc = tauchen(10, ρ, σ_z, μ, n_std), tol = 1e-7)
p = RBCModel()
# Compute steady state capital and consumption
kss = ((1/p.β − 1 + p.δ)/p.α)^(1/(p.α−1))
css = kss^(p.α)-p.δ*kss
# Compute range for potential capital levels
k_grid = range(0.5*kss, 2*kss, p.Kn-1)
kss_id = findlast(k_grid .< kss)
k_grid = [k_grid[1:kss_id]; kss; k_grid[kss_id+1:end]]
# Benchmarking exercise
resource_constraint_anon(c) = resource_constraint(c, k_grid[1], k_grid[37], p.mc.state_values[1]; p)
# This will work
cs = find_zero(resource_constraint_anon, css/2)
# This will fail
cs = find_zero(resource_constraint_anon, css)
```