# Approximation of Riemann integrable function with a continuous function

I have proved that if $f \in R[a,b]$ and given $\epsilon > 0$ there exists a continuous function $g$ such that $$\int_a^b |f-g| < \epsilon$$ I was wondering if using this fact there is some way to show that there is also some continuous function $h$ such that $$\int_a^b |f-h|^2 < \epsilon$$ Any help will be appreciated, thanks :)

Since $f$ is Riemann integrable, it is bounded, say $|f| \le M$. Now, given $\epsilon>0$ we can find a continuous $g$ such that $|g| \le M$ and

$$\int_a^b |f-g| \, dx < \frac{\epsilon}{2M}$$

For example find a continuous $h$ which approximates $f$, i.e. $\int |f-h| \, dx < \epsilon/2M$ and set $$g(x) = \begin{cases} \min(M, h(x)) & h(x) \ge 0 \\\ \max(-M, h(x)) & h(x) < 0\end{cases}$$

Then, with this $g$, we have

$$\int_a^b |f-g|^2 \, dx \le \int_a^b |f-g|(|f|+|g|)\, dx \le 2M \int_a^b |f-g| \, dx < \epsilon$$

• Does Riemann integrable require bounded? Are convergent improper integrals not considered Riemann integrable? – Aaron Jun 7 '11 at 1:47
• @Aaron: Yes. A function is Riemann integrable iff it is bounded and its set of discontinuities has Lebesgue measure zero. – t.b. Jun 7 '11 at 1:52
• @Theo Buehler Drat, that means my solution is irrelevant. I was taking integrable in the extended sense. – Aaron Jun 7 '11 at 1:59
• @Aaron: Just keep it there, it doesn't hurt to have that additional information :) – t.b. Jun 7 '11 at 2:01
• The question wants a function to approximate $f$ . You say we find a function and then we find another function using the first one :| ( $g$ is defined using $h$.) – Arman Malekzadeh Jan 10 '17 at 7:52

Note: Instead of using Riemann integrable in the usual sense here, I have used it in the sense of convergent improper integrals. If the discussion seems more complicated than is necessary, that is why.

You need to add in the condition that $f^2(x)$ is Riemann integrable. To see why, consider the function $f(x)=x^{-3/4}$ if $x\in (0,1]$ and $f(0)=0$. This is Riemann integrable, but for any continuous function on $[0,1]$ $(f(x)-g(x))^2$ will NOT be integrable. So let us add this condition to our discussion.

If you replace "Riemann integral" replaced with "Lebesgue integral", this result is standard material in any course on measure theory. More generally, one can show that continuous functions are dense in $L^p([a,b])$, the collection of functions that are integrable when you take them to the $p$th power. In your particular case, the integral you are using is the (square of) the distance in $L^2([a,b])$ between $f$ and $h$. Because Riemann integrable functions are also Lebesgue integrable functions, the result follows.

I do not believe that you can prove the second result strictly from the first because, even if $\int_a^b |f(x)-g(x)|dx$ is small, there could be places where $|f(x)-g(x)|$ is very large, and so integrating the difference squared might be infinite. You can construct an example by using the fact that $\sum \frac{n^2}{n^4}<\infty$ but $\sum \frac{(n^2)^2}{n^4}$ diverges. Since good approximations without squaring are not necessarily good approximations with squaring, you need to actually be precise about how you are doing your approximating.

If you add the hypothesis that $f$ is bounded, the new result will follow from the old one, because you can bound $\int_a^b |f(x)-g(x)|^2dx<(\max |f-g|)\int_a^b |f(x)-g(x)|dx$

If you want to see how everything is done in the case of the Lebesgue integral, I recommend Rudin's "Real and Complex Analysis". (I would include a link to google books, but the book is not readable there).
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://math.stackexchange.com/questions/43782/approximation-of-riemann-integrable-function-with-a-continuous-function", "fetch_time": 1568836710000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2019-39/segments/1568514573331.86/warc/CC-MAIN-20190918193432-20190918215432-00027.warc.gz", "warc_record_offset": 557207699, "warc_record_length": 32361, "token_count": 1078, "char_count": 3629, "score": 3.578125, "int_score": 4, "crawl": "CC-MAIN-2019-39", "snapshot_type": "latest", "language": "en", "language_score": 0.8552238941192627, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00024-of-00064.parquet"}