# 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:** 20\
**Page:** 1

<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 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/1 "2020-10-23T20:46:25Z")

</div>

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

```julia
# Begin Preamble 
using LinearAlgebra
using GeneralizedGenerated #
using ApproxFun, Test
    import ApproxFunBase: testfunctional, testbandedoperator
using SpecialFunctions

## Avazzadev et al # Example 1
 ctoli_Q1=gamma(0.5)*LeftIntegral(0.5)
 r_left_x = 0.0 ; r_right_x = 1.0
 fun_f1=mk_function(
           Meta.parse("x -> ApproxFun.Fun(Chebyshev(Domain(r_left_x..r_right_x)),
                                                2/105*sqrt(x)*(105-56x^2+48x^3))" )
       )
# 
# Tried next line 
fun_f1=ApproxFunBase.setdomain(fun_f1,r_left_x..r_right_x)
# But then receive this ERRROR: >>
ERROR: LoadError: MethodError: no method matching setdomain(::ggfunc,::IntervalSets.Interval{:closed,:closed,Float64})
Closest candidates are: ..

## Then I try to set the space unambiguously so that the space is known, and so does not need to be inferred here >>  
  funjac_u1=Fun( Chebyshev(Domain(r_left_x..r_right_x)), ctoli_Q1\fun_f1 )

But I keep getting this issue :
ERROR: LoadError: Cannot infer spaces
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] \(::ApproxFunBase.ConstantTimesOperator{ApproxFun.ConcreteLeftIntegral{ApproxFunBase.UnsetSpace,Float64,Float64},Float64}, :: **ggfunc;** kwds::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/marc/.julia/packages/ApproxFunBase/92sMu/src/Operators/ldiv.jl:7
.
.

            if isambiguous(domainspace(A))
		..
		[7] isambiguous(sp::Space) in ApproxFunBase at /home/marc/.julia/packages/ApproxFunBase/92sMu/src/Space.jl:102
			.. isambiguous(sp::Space) = isambiguous(rangetype(sp))

```

Any hints or tips are appreciated Thanks !

---

<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:** [October 23, 2020, 9:11pm 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/2 "2020-10-23T21:11:56Z")

</div>

I’m a bit confused what you are trying to do: note that it is not a good idea to expand `sqrt(x)` times a polynomial in a Chebyshev (polynomial) expansion.

That said the code seems to be broken as it is trying to use `lgamma` which is now called `loggamma`. Please file a GitHub issue.

---

<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 23, 2020, 11:36pm 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/3 "2020-10-23T23:36:04Z")

</div>

Thank You for putting together this wonderful package, and also for looking into this.  
Sorry if unclear, I’m new to ApproxFun and trying to intuitively feel my way around it  
by trying out things …

Re:

> - I’m a bit confused what you are trying to do: note that it is not a good idea to expand sqrt(x) times a polynomial in a Chebyshev (polynomial) expansion.

As for ? what you are trying to do ? Look in **folder** : … /.julia/dev/ApproxFun/test **file:** FractionalTest.jl , specifically this **Section:**

```julia
    ## Avazzadev et al
    # Example 1
    x=Fun(0..1)
    Q=gamma(0.5)*LeftIntegral(0.5)
    @time f=(2/105*sqrt(x)*(105-56x^2+48x^3))
    u=Q\f
    @test norm(u-(x^3-x^2+1))<100eps()

```

So I am trying adapt the code above plus using GeneralizedGenerated so that we can use ApproxFun to take the Fractional Derivative of any arbitrary function defined in parseable String – below is the

```julia
Pseudo Code for that >>
    using GeneralizedGenerated #
    using ApproxFun, Test
    import ApproxFunBase: testfunctional, testbandedoperator
    using SpecialFunctions

        ## Avazzadev et al # Example 1           
	    x=Fun(0..1)
        Q=gamma(0.5)*LeftIntegral(0.5)
   	    f=mk_function(
            Meta.parse( "x -> ApproxFun.Fun(2/105*sqrt(x)*(105-56x^2+48x^3))" )
                          )
    u=Q\f
    @test norm(u-(x^3-x^2+1))<100eps()

```

I think there was also some work done towards this here \>\> [Using ApproxFun for dynamic programming](https://discourse.julialang.org/t/using-approxfun-for-dynamic-programming/1754) \<\< but only with regards to limiting accuracy to save compute cycles during numerous iterations , but not so much about using ApproxFun to take the Fractional Derivative of **any arbitrary function defined in a parsable String,** by the way I’m also interested in any other symbolic equation function form you might suggest besides Strings.

Re:

- _That said the code seems to be broken as it is trying to use lgamma which is now called loggamma. Please file a GitHub issue._

As for “ … _Please file a GitHub issue … trying to use lgamma which is now called loggamma._ “ I’ll be glad to file a GitHub issue if I can help you out , but that doesn’t seem to be (at least not directly) related to my immediate issue of parsing in arbitrary functions to ApproxFun, possibly because I’m already `using SpecialFunctions` as a workaround ?

---

<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 23, 2020, 11:51pm 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/4 "2020-10-23T23:51:44Z")

</div>

Ok so MWE code below is how to recreate this Error message \>\>

```julia
ERROR: LoadError: Cannot infer spaces
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] \(::ApproxFunBase.ConstantTimesOperator{ApproxFun.ConcreteLeftIntegral{ApproxFunBase.UnsetSpace,Float64,Float64},Float64}, ::ggfunc; kwds::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/marc/.julia/packages/ApproxFunBase/92sMu/src/Operators/ldiv.jl:7
 [3] \(::ApproxFunBase.ConstantTimesOperator{ApproxFun.ConcreteLeftIntegral{ApproxFunBase.UnsetSpace,Float64,Float64},Float64}, ::ggfunc) at /home/marc/.julia/packages/ApproxFunBase/92sMu/src/Operators/ldiv.jl:4

```

**MWE code in a nutshell below \>\>** `Preformatted text`

```julia
# As for ? what you are trying to do ?
# Look in folder: … /.julia/dev/ApproxFun/test file: FractionalTest.jl ,
# specifically this Section:
#
# ## Avazzadev et al
# # Example 1
# x=Fun(0..1)
# Q=gamma(0.5)*LeftIntegral(0.5)
# @time f=(2/105*sqrt(x)*(105-56x^2+48x^3))
# u=Q\f
# @test norm(u-(x^3-x^2+1))<100eps()
#
# So I am trying adapt the code above
# plus using GeneralizedGenerated
# so that we can use ApproxFun to take the Fractional Derivative of any arbitrary function
# defined in parseable String – below is the
# Pseudo Code for that >>
    using GeneralizedGenerated #
    using ApproxFun, Test
    import ApproxFunBase: testfunctional, testbandedoperator
    using SpecialFunctions

        ## Avazzadev et al # Example 1
	    x=Fun(0..1)
        Q=gamma(0.5)*LeftIntegral(0.5)
   	    f=mk_function(
                      Meta.parse( "x -> ApproxFun.Fun(2/105*sqrt(x)*(105-56x^2+48x^3))" )
                	 )
    u=Q\f
    @test norm(u-(x^3-x^2+1))<100eps()

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 24, 2020, 12:49am 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/5 "2020-10-24T00:49:53Z")

</div>

What about with RuntimeGeneratedFunctions.jl?

---

<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 24, 2020, 1:42am 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/6 "2020-10-24T01:42:18Z")

</div>

Thanks Chris ! RuntimeGeneratedFunctions.jl looks promising. I will try it out tomorrow !

---

<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:** [October 24, 2020, 8:51am 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/7 "2020-10-24T08:51:27Z")

</div>

This is the line that’s confusing:

> [@Marc.Cox](#):
>
> ```julia
> Meta.parse( "x -> ApproxFun.Fun(2/105*sqrt(x)*(105-56x^2+48x^3))" )
> )
> 
> ```

It looks very different to the example code so I’m not sure what you’re trying to do. Note on the example `x = Fun(0..1)` so is an instance of type `Fun`.

Note I’m in the process of revamping ApproxFun.jl as OrthogonalPolynomialsQuasi.jl, in part to make what the linked post was trying to do a lot easier. Eg one can now fix a truncation size via

```Julia
T = Chebyshev()
T[:,1:n] # first n Chebyshev polynomials

```

Coincidentally I have a phd student adding support for fractional derivatives as we speak. So if you need the “dynamic” part it might be best to use that, I can Try to get the example code working in the next few weeks.

---

<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 24, 2020, 8:12pm 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/8 "2020-10-24T20:12:52Z")

</div>

> [@dlfivefifty](#):
>
> Coincidentally I have a phd student adding support for fractional derivatives as we speak. So if you need the “dynamic” part it might be best to use that, I can Try to get the example code working in the next few weeks.

Sounds Great and Thank You please keep me apprised 👍😃 👍

Btw yes @dlfivefifty now that we have the Fractional Calculus parts working, the (iterative) Dynamic function evaluation part is what I’m interested most in , and fyi @dlfivefifty && @ChrisRackauckas per the error message below it appears the issue of “Dynamism” may now be a matter of ApproxFun doesn’t (yet?) recognize type` ::RuntimeGeneratedFunction` (or such) as a bona fide subtype of` ::Fun`

```julia
ERROR: LoadError: MethodError: no method matching extrapolate(::RuntimeGeneratedFunction{(:u,)}, ::Float64)
Closest candidates are:
  extrapolate(::Fun, ::Any) at /home/marc/.julia/
packages/ApproxFunBase/92sMu/src/Fun.jl:237
  extrapolate(::Fun, ::Any, ::Any, ::Any...) at /home/marc/.julia
/packages/ApproxFunBase/92sMu/src/Fun.jl:238
Stacktrace:
 [1] (::var"#20#21")(::Float64) at ./none:0

```

---

<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 24, 2020, 8:56pm 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/9 "2020-10-24T20:56:03Z")

</div>

Thanks for the suggestion Chris, Here is what I know (so far) …

… per the error message below it appears the issue of “Dynamism” may now be a matter of ApproxFun doesn’t (yet?) recognize type` ::RuntimeGeneratedFunction` (or such) as a bona fide subtype of` ::Fun`

```julia
ERROR: LoadError: MethodError: no method matching extrapolate(::RuntimeGeneratedFunction{(:u,)}, ::Float64)
Closest candidates are:
  extrapolate(::Fun, ::Any) at /home/marc/.julia/
packages/ApproxFunBase/92sMu/src/Fun.jl:237
  extrapolate(::Fun, ::Any, ::Any, ::Any...) at /home/marc/.julia
/packages/ApproxFunBase/92sMu/src/Fun.jl:238
Stacktrace:
 [1] (::var"#20#21")(::Float64) at ./none:0

```

And so now I’ll dive further into the mystery of the ancient arcana , hey think we might get the guy with the really cool Aussie hat sometimes known as @c42f Code name: _c42f_ to take a look too ? You know in case I get too far inside an underwater cave without a map etc. 😬

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 24, 2020, 9:35pm 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/10 "2020-10-24T21:35:50Z")

</div>

You defined a function with 1 input and tried to call it with 2.

---

<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 25, 2020, 12:08am 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/12 "2020-10-25T00:08:55Z")

</div>

Nope, Try this MWE / snippet out \>\>

```julia
		## Copied from above, Uncomment if needed.
		# using ApproxFun, Test
	    # import ApproxFunBase: testfunctional, testbandedoperator
	    # using SpecialFunctions
		# # using LinearAlgebra # nix if DUMP norm
		# using Statistics
		# #
		# using BenchmarkTools # Provides @btime for best case vs @time for worst case
		##
		## Avazzadev et al # Example 1
		x = Fun(0..1)
		Q = gamma(0.5)*LeftIntegral(0.5)
		#
		func_f4 = Meta.parse( "x -> 2/105*sqrt(x)*(105-56x^2+48x^3)" )
		func_f5 = @RuntimeGeneratedFunction(func_f4)
		println("##140 typeof(func_f5),typeof(func_f5()):=",
						typeof(func_f5))
		# Attempt to Dynamically define u=Q\f , or in this case u=Q\func_f5
		func_f6 = Meta.parse( "u -> Q\\func_f5" )
		func_f7 = @RuntimeGeneratedFunction(func_f6)
		println("##145 typeof(func_f7):=",typeof(func_f7))
		##145 typeof(func_f7):=RuntimeGeneratedFunction{(:u,)}
		##
		# NOTE BEWARE This is effectively SAMPLE RATE ! and a Possible BUG per NOT actually part of Approximating Function definition range/domain
		r_left_x = 0.0; r_length_sample_range_x = 200; r_right_x = 1.0
		range_x = range(r_left_x,
	                stop=r_right_x,
					length=convert(Integer,r_length_sample_range_x)
					); # a non-default grid
		# Previous working syntax template r_temp1 = Statistics.mean(ApproxFun.extrapolate(funjac_u1,r_x) for (r_x) in range_x)
		r_temp1 = Statistics.mean(ApproxFun.extrapolate(func_f7,r_x) for (r_x) in range_x)

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 25, 2020, 12:09am 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/13 "2020-10-25T00:09:29Z")

</div>

That’s a doozy of an example. Maybe @c42f has an idea.

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [October 25, 2020, 6:00am 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/14 "2020-10-25T06:00:07Z")

</div>

> [@Marc.Cox](#):
>
> ApproxFun doesn’t (yet?) recognize type ` ::RuntimeGeneratedFunction` (or such) as a bona fide subtype of ` ::Fun`

Well it looks like `ApproxFun.extrapolate` only works with `Fun`, not `Function` in general. So the error you’ve got seems independent of `RuntimeGeneratedFunction`. You get the same error if you try to put in a normal function:

```julia
julia> ApproxFun.extrapolate(x->x, 1.0)
ERROR: MethodError: no method matching extrapolate(::var"#14#15", ::Float64)
Closest candidates are:
  extrapolate(::Fun, ::Any) at /home/chris/.julia/packages/ApproxFunBase/rkmP0/src/Fun.jl:237
  extrapolate(::Fun, ::Any, ::Any, ::Any...) at /home/chris/.julia/packages/ApproxFunBase/rkmP0/src/Fun.jl:238
Stacktrace:
 [1] top-level scope at REPL[14]:1

```

---

<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:** [October 25, 2020, 9:28pm 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/15 "2020-10-25T21:28:51Z")

</div>

To be honest I’m completely lost, but we could probably add a fallback `extrapolate(f::Function, x) = f(x)`.

Note that you’ll need to wait til

[https://github.com/JuliaApproximation/ApproxFun.jl/pull/720](https://github.com/JuliaApproximation/ApproxFun.jl/pull/720)

is merged: fractional calculus was not being tested (due to a type-inference bug that was fixed in 1.3 or so) and stopped working.

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [October 26, 2020, 2:18am 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/16 "2020-10-26T02:18:03Z")

</div>

Yeah I should say I don’t know anything about `ApproxFun` or about the application here so I don’t know whether putting a `RuntimeGeneratedFunction` into `extrapolate` makes sense.

But I thought maybe it’s a just a bug in the example code, as this same code wouldn’t work even with normal closures?

---

<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 …

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 26, 2020, 4:36pm 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/18 "2020-10-26T16:36:49Z")

</div>

> [@Marc.Cox](#):
>
> `using RuntimeGeneratedFunctions.jl even beats Generalizedgenerated.jl for generalized generated functions`

Dang, missed opportunity. It could’ve been GeneralizedGeneralizedGenerated.jl

---

<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:41pm 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/19 "2020-10-26T16:41:22Z")

</div>

😂 🕶 👍

---

<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, 6:04pm 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/20 "2020-10-26T18:04:33Z")

</div>

> [@dlfivefifty](#):
>
> Eg one can now fix a truncation size via
> 
> ```julia
> T = Chebyshev()
> T[:,1:n] # first n Chebyshev polynomials
> 
> ```

Thank You very much Sheehan @dlfivefifty ^This will absolutely be helpful for managing and metering CPU cycles/time spent on each iteration while searching for solutions … what are your thoughts about doing the same for Jacobi etc. ?

---

<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, 7:03pm 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/21 "2020-10-26T19:03:44Z")

</div>

> [@Future directions of Julia](https://discourse.julialang.org/t/future-directions-of-julia/46269/4):
>
> I want all simulations to run instantly and if your model is incorrect but you have data, then I want the computer to tell you how to fix your model and then instantly simulate it.

👍 🕶 👍

[Next page](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.md?page=2)
