# Setting ApproxFun Space , tried several tricks but still receive \*\*ERROR: LoadError: Cannot infer spaces\*\* – specifically when using GeneralizedGenerated.jl for Generalized generated functions

**URL:** <https://discourse.julialang.org/t/setting-approxfun-space-tried-several-tricks-but-still-receive-error-loaderror-cannot-infer-spaces-specifically-when-using-generalizedgenerated-jl-for-generalized-generated-functions/48909>\
**Category:** Numerics\
**Created:** [October 23, 2020, 8:46pm UTC](https://discourse.julialang.org/t/setting-approxfun-space-tried-several-tricks-but-still-receive-error-loaderror-cannot-infer-spaces-specifically-when-using-generalizedgenerated-jl-for-generalized-generated-functions/48909 "2020-10-23T20:46:25Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![Marc.Cox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc.cox/32/7514_2.png) [@Marc.Cox](https://discourse.julialang.org/u/Marc.Cox)\
**Post date:** [October 26, 2020, 4:26pm UTC](https://discourse.julialang.org/t/setting-approxfun-space-tried-several-tricks-but-still-receive-error-loaderror-cannot-infer-spaces-specifically-when-using-generalizedgenerated-jl-for-generalized-generated-functions/48909/17 "2020-10-26T16:26:41Z")

</div>

Thank you All for your input and insights !  
You motivated me to push on until we found an answer together !

Ok so I’d like to take a swing at recapping  
what we’ve learned so far here …

```julia
### 
# Template solution motivated by @Chris_Foster and @ChrisRackauckas Thanks Chrisss^2 :-) !
# .. Marc BEGIN WORKS NOW !!

julia> func_f161 = @RuntimeGeneratedFunction(Meta.parse("f16(x) = x"))
# Julia response @RuntimeGeneratedFunction( >>
RuntimeGeneratedFunction(#=in Main=#, :((x,)->begin
          #= none:1 =#
          x
      end))

julia> f17 = ApproxFun.Fun(x->func_f161(x),Domain(0.0..10.0))
# Julia response ApproxFun.Fun( >>
Fun(Chebyshev(0.0..10.0),[5.0, 5.000000000000001])

julia> f17(1)
0.9999999999999991

julia> f17(7)
7.000000000000001

julia> @btime f17(7)
  26.122 ns (1 allocation: 16 bytes)
7.000000000000001
## Yay !! good job Chris using RuntimeGeneratedFunctions.jl even beats Generalizedgenerated.jl for generalized generated functions

#
# .. Marc END WORKS NOW !!
###

```

Ps\> @dlfivefifty Now that the above code works for defining Dynamic functions specified by a String would you like me to Test it out , clean it up, and possibly create a PR ?

… And Hope you all are up for another Question ?  
It’s really for everyone but I’m guessing @dlfivefifty or @ChrisRackauckas might know off the top of their heads about why this section of Code:

```julia
julia> f17 = ApproxFun.Fun(x->func_f161(x),Domain(0.0..10.0))
# Julia response ApproxFun.Fun( >>
Fun(Chebyshev(0.0..10.0),[5.0, 5.000000000000001])

```

Note it doesn’t appear until specify the `Domain(` ,  
so to develop Mathematical theory intuition further pls  
where and why does the` [5.0, 5.000000000000001]` come from ?

… And @c42f and @dlfivefifty I have more questions about quickly handling / removing `Inf` from answers (possibly as `Missing` instead ) because` Inf` really renders `LinearAlgebra.norm(` and `Statistics.mean(` useless for further Tests or analysis ;  
but I’m trying (but failing ? LOL 🙂 ) to keep things bite size and not “Fire Hose” everyone …

---

_[View the full topic](https://discourse.julialang.org/t/setting-approxfun-space-tried-several-tricks-but-still-receive-error-loaderror-cannot-infer-spaces-specifically-when-using-generalizedgenerated-jl-for-generalized-generated-functions/48909)._
