# ApproxFun Tutorials Discretization Error

**URL:** <https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612>\
**Category:** Numerics\
**Tags:** question\
**Created:** [July 29, 2024, 8:21pm UTC](https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612 "2024-07-29T20:21:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Domenico\_Lahaye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/domenico_lahaye/32/203728_2.png) [@Domenico\_Lahaye](https://discourse.julialang.org/u/Domenico_Lahaye)\
**Post date:** [July 29, 2024, 8:21pm UTC](https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612/1 "2024-07-29T20:21:20Z")

</div>

How can the accuracy in the computed solution in the ApproxFun Tutorials be adapted/changed? Is there a way top set the number of basis functions being used for e.g. a coarse, intermediate and fine scale approximation? How would one perform a test of the reduction of discretization error as the number of basis functions is increased?

Why does backslach require a tolerance setting for linear problems? What is this tolerence used?

---

<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:** [July 29, 2024, 9:36pm UTC](https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612/2 "2024-07-29T21:36:02Z")

</div>

There’s just a tolerance flag that measures the error in residual

For spectral methods it’s not that important as the DOF don’t increase that much if you lower the tolerance. Your “course” “intermediate” “fine” language is more relevant for h-refinement not p-refinement

---

<div class="post-metadata">

**Author:** ![Domenico\_Lahaye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/domenico_lahaye/32/203728_2.png) [@Domenico\_Lahaye](https://discourse.julialang.org/u/Domenico_Lahaye)\
**Post date:** [July 30, 2024, 5:56am UTC](https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612/3 "2024-07-30T05:56:28Z")

</div>

Clear, thanks, understood.

Still, being naughty and stubborn, is there a way to override the default way of working with ApproxFun? I would like to set (predetermine, fix) the number of expansion terms prior to the linear solve. My interest here is two-fold. First, performing a study of discretization error. Second, seek ways to use ApproxFun to implement a harmonic balance method. In this method, one typically predetermines the number of harmonics.

I am not sure whether using

```julia
x = points(S, n)

```

as done in this [Example](https://docs.sciml.ai/SciMLBenchmarksOutput/html/MOLPDE/burgers_spectral_wpd.html)  
goes in the direction I am interested in.

Additional input is very much appreciated.

---

<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:** [July 30, 2024, 6:15am UTC](https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612/4 "2024-07-30T06:15:11Z")

</div>

ClassicalOrthogonalPolynomials.jl might be better suited for your needs

---

<div class="post-metadata">

**Author:** ![Domenico\_Lahaye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/domenico_lahaye/32/203728_2.png) [@Domenico\_Lahaye](https://discourse.julialang.org/u/Domenico_Lahaye)\
**Post date:** [July 30, 2024, 9:44pm UTC](https://discourse.julialang.org/t/approxfun-tutorials-discretization-error/117612/5 "2024-07-30T21:44:09Z")

</div>

Many thanks. I will give it a look.
