# Solving for eigenvalues of an equation system in ApproxFun.jl

**URL:** <https://discourse.julialang.org/t/solving-for-eigenvalues-of-an-equation-system-in-approxfun-jl/33682>\
**Category:** Numerics\
**Created:** [January 23, 2020, 4:54am UTC](https://discourse.julialang.org/t/solving-for-eigenvalues-of-an-equation-system-in-approxfun-jl/33682 "2020-01-23T04:54:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbmuir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbmuir/32/4798_2.png) [@jbmuir](https://discourse.julialang.org/u/jbmuir)\
**Post date:** [January 23, 2020, 4:54am UTC](https://discourse.julialang.org/t/solving-for-eigenvalues-of-an-equation-system-in-approxfun-jl/33682/1 "2020-01-23T04:54:44Z")

</div>

I’m trying to solve an eigenvalue problem for a system of equations using `ApproxFun`; however I’m getting an implementation error `ERROR: Implement Conversion from Chebyshev{Interval{:closed,:closed,Int64},Float64} to ApproxFunBase.UnsetSpace`. I suspect that I’m just misformulating something as its the first time I’ve used the package - any tips? Not-working MWE below:

```julia
using ApproxFun

d = Interval(0,1000)
μ = 1e9
ρ = 1000.0

D = Derivative(d)
ω = 1.0

Bu = lneumann(d)
Bl = rdirichlet(d)

B = [Bu 0;
     Bl 0]

I = ones(d)

L = [0 I/μ;
     ρ*ω^2*I+D*μ*D 0]

λ, v = ApproxFun.eigs(B, L, 500,tolerance=1E-10)

```

---

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [January 23, 2020, 8:21am UTC](https://discourse.julialang.org/t/solving-for-eigenvalues-of-an-equation-system-in-approxfun-jl/33682/2 "2020-01-23T08:21:50Z")

</div>

You’ve defined `I` to be `Fun`, that is, its equivalent to `Fun(1, d)`, so ApproxFun doesn’t understand what you want. It’s also probably a bad idea to overwrite `I` anyways. So I would do:

```julia
E = Operator(I,d)

L = [0 E/μ;
            ρ*ω^2*I+D*μ*D 0]

```

That said, you are trying to compute over a domain of size `1000` and so you’ll probably need `20_000` discretization size before you see anything, which may be too high for `eigs` which uses dense generalized eigenvalue solver. Using inverse iteration would be better.

---

<div class="post-metadata">

**Author:** ![jbmuir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbmuir/32/4798_2.png) [@jbmuir](https://discourse.julialang.org/u/jbmuir)\
**Post date:** [January 23, 2020, 5:32pm UTC](https://discourse.julialang.org/t/solving-for-eigenvalues-of-an-equation-system-in-approxfun-jl/33682/3 "2020-01-23T17:32:04Z")

</div>

Thanks - for this type of problem you can normally have a good guess for the eigenvalue you want so that should help - is there some out-of-the-box support for inverse iteration in ApproxFun or is it implement yourself?

---

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [January 24, 2020, 11:02am UTC](https://discourse.julialang.org/t/solving-for-eigenvalues-of-an-equation-system-in-approxfun-jl/33682/4 "2020-01-24T11:02:23Z")

</div>

It’s pretty easy to implement, something like

```julia
μ = 0.1 # guess of eigenvalue
u = Fun(1, d) # initial guess of eigenvector
v = Fun(1, d) 
for _=1:100
   u,v = [B; L - μ*I] \ [0,0,u,v]
   n = norm(u)+norm(v)
   u /= n
   v /= n
end

```
