Example of a continuous function that is difficult to approximate with polynomials
Clash Royale CLAN TAG#URR8PPP
up vote
11
down vote
favorite
For teaching purposes I'd need a continuous function of a single variable that is "difficult" to approximate with polynomials, i.e. one would need very high powers in a power series to "fit" this function well. I intend to show my students the "limits" of what can be achieved with power series.
I thought about concocting something "noisy", but instead of rolling my own I am just wondering whether there is a kind of standard "difficult function" that people use for testing approximation / interpolation algorithms, somewhat similarly to those optimisation test functions that have numerous local minima where naive algorithms get stuck easily.
Apologies if this question is not well-formed; please have mercy on a non-mathematician.
interpolation
add a comment |Â
up vote
11
down vote
favorite
For teaching purposes I'd need a continuous function of a single variable that is "difficult" to approximate with polynomials, i.e. one would need very high powers in a power series to "fit" this function well. I intend to show my students the "limits" of what can be achieved with power series.
I thought about concocting something "noisy", but instead of rolling my own I am just wondering whether there is a kind of standard "difficult function" that people use for testing approximation / interpolation algorithms, somewhat similarly to those optimisation test functions that have numerous local minima where naive algorithms get stuck easily.
Apologies if this question is not well-formed; please have mercy on a non-mathematician.
interpolation
add a comment |Â
up vote
11
down vote
favorite
up vote
11
down vote
favorite
For teaching purposes I'd need a continuous function of a single variable that is "difficult" to approximate with polynomials, i.e. one would need very high powers in a power series to "fit" this function well. I intend to show my students the "limits" of what can be achieved with power series.
I thought about concocting something "noisy", but instead of rolling my own I am just wondering whether there is a kind of standard "difficult function" that people use for testing approximation / interpolation algorithms, somewhat similarly to those optimisation test functions that have numerous local minima where naive algorithms get stuck easily.
Apologies if this question is not well-formed; please have mercy on a non-mathematician.
interpolation
For teaching purposes I'd need a continuous function of a single variable that is "difficult" to approximate with polynomials, i.e. one would need very high powers in a power series to "fit" this function well. I intend to show my students the "limits" of what can be achieved with power series.
I thought about concocting something "noisy", but instead of rolling my own I am just wondering whether there is a kind of standard "difficult function" that people use for testing approximation / interpolation algorithms, somewhat similarly to those optimisation test functions that have numerous local minima where naive algorithms get stuck easily.
Apologies if this question is not well-formed; please have mercy on a non-mathematician.
interpolation
asked Sep 6 at 13:23
Laryx Decidua
19610
19610
add a comment |Â
add a comment |Â
5 Answers
5
active
oldest
votes
up vote
10
down vote
Why not simply show the absolute value function?
Approximation with e.g. Legendre-polynomial expansion works, but pretty badly:
Taylor expansion is of course completely useless here, always giving only a linear function, either always decreasing or always increasing (depending on whether the point you expand around is negative or positive).
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
 |Â
show 1 more comment
up vote
8
down vote
It's a pathological case, but you can always resort to the Weierstrass monster function. It illustrates a broader point, namely that functions that are not smooth -- e.g., that have a kink -- are difficult to approximate because the interpolation error estimates require the function being interpolated to be differentiable a number of times. In other words, if you don't like the Weierstrass function too much, you can always just choose $|x|$.
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
add a comment |Â
up vote
6
down vote
Approximation is not only made hard by the function to be approximated but by the interval in which the approximation should be a "good fit". And you should define the measure for a "good fit", i.e. what is the maximum (absolute or relative) error you wish to tolerate?
For example, you will need a huge number of terms in the Taylor series of $exp(x)$ to have a reasonable fit on the interval $[0,10]$. The same holds for periodic functions. Take $sin(x)$, for example, on the interval $[0,2pi]$. See pictures below...
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
add a comment |Â
up vote
4
down vote
Polynomials are surprisingly effective at function approximation [1]. If you have at least Lipschitz continuity, then Chebyshev approximations will converge. Of course, convergence may be slow, and that is the price we pay for dealing with a non-smooth function.
Today, computers are much faster than the days in which many numerical analysis books were written, and clever algorithms have increased the speed further, so that having to use more terms may not be as bad as it used to be.
The pathological examples like Weierstrass monster function are interesting from a theoretical point of view, but they are not representative of most real application contexts.
I think we should be careful not to give a pessimistic view to our students. Ok, there is no method that works for all problems. But we can build adaptive methods, say even based on polynomials, that can deal with such cases. For example, Chebfun [2] can easily approximate $|x|$ by automatically splitting the domain at $x=0$.
It is important to teach the difficulties in approximation with polynomials, but it also important to tell the students that we can build error estimates and adaptive algorithms that can deal with these issues.
[1] https://people.maths.ox.ac.uk/trefethen/mythspaper.pdf
[2] http://www.chebfun.org
add a comment |Â
up vote
2
down vote
$f(x) = frac1x^2+1$ has this Maclaurin series expansion:
$frac1x^2+1 = 1-x^2+x^4-x^6+x^8-x^10+x^12 - ldots$
This converges for $-1<x<1$, but it diverges everywhere else. A polynomial approximation around $x=0$ will never get you anywhere near the right answer for $x=2$.
New contributor
add a comment |Â
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
Why not simply show the absolute value function?
Approximation with e.g. Legendre-polynomial expansion works, but pretty badly:
Taylor expansion is of course completely useless here, always giving only a linear function, either always decreasing or always increasing (depending on whether the point you expand around is negative or positive).
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
 |Â
show 1 more comment
up vote
10
down vote
Why not simply show the absolute value function?
Approximation with e.g. Legendre-polynomial expansion works, but pretty badly:
Taylor expansion is of course completely useless here, always giving only a linear function, either always decreasing or always increasing (depending on whether the point you expand around is negative or positive).
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
 |Â
show 1 more comment
up vote
10
down vote
up vote
10
down vote
Why not simply show the absolute value function?
Approximation with e.g. Legendre-polynomial expansion works, but pretty badly:
Taylor expansion is of course completely useless here, always giving only a linear function, either always decreasing or always increasing (depending on whether the point you expand around is negative or positive).
Why not simply show the absolute value function?
Approximation with e.g. Legendre-polynomial expansion works, but pretty badly:
Taylor expansion is of course completely useless here, always giving only a linear function, either always decreasing or always increasing (depending on whether the point you expand around is negative or positive).
answered Sep 6 at 22:04
leftaroundabout
26115
26115
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
 |Â
show 1 more comment
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
You can interpolate |x| using Chebyshev interpolation, see nbviewer.jupyter.org/github/cpraveen/na/blob/master/⦠which converges quite fast. E.g., you can change N=2*i in the code to N=15+i and test larger degree. It is not an expansion method but still based on polynomials.
â Praveen Chandrashekar
Sep 7 at 2:26
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
@PraveenChandrashekar Chebyshev works âÂÂbetterâ because it puts more weight on the outer parts of the interval, where the function is smooth. Thus the excessive oscillation is avoided, but saying it approximates the function better is dubious â it does in particular capture the sharp turn at $x=0$ even worse than uniform-discrete-points or $L^2$-minimisation. If your goal is avoiding high-frequency components, better use an integral transformation that properly damps these components.
â leftaroundabout
Sep 7 at 9:59
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
It is perfectly fine to have non-uniform points as in Chebyshev interpolation. With degree about 20, it gives a lot more accurate approximation than Legendre that you show in your post. Measure the errors to be more quantitative. You can also do Chebyshev series approximation of |x| which is more accurate than Legendre expansion.
â Praveen Chandrashekar
Sep 7 at 16:02
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
@PraveenChandrashekar the point is that polynomials are in principle not able to approximate a function like $x mapsto |x|$ properly. There are different methods each of which fails a bit more or less spectacularly, but none of them work well in the sense of âÂÂonly a few terms give something that could be mistaken for the original functionâÂÂ. If you must use polynomials, you need to consider which kinds of error are more problematic, Legendre and Chebyshev both have their use cases but there's no silver bullet. Ultimately, an approach with e.g. splines is typically more effective.
â leftaroundabout
Sep 7 at 17:52
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
We know there is no perfect method. The question is what functions are difficult for polynomials to approximate. So one has to see all possible methods involving polynomials to conclude none of them do a good job. The Legendre is not the best way to approximate |x| and hence it gives a rather false impression that polynomials are too bad for |x|. With Chebyshev you have convergence and far better approximations than Legendre, they dont oscillate so badly as Legendre, though converge slowly near x=0, where function is not smooth enough.
â Praveen Chandrashekar
Sep 8 at 2:42
 |Â
show 1 more comment
up vote
8
down vote
It's a pathological case, but you can always resort to the Weierstrass monster function. It illustrates a broader point, namely that functions that are not smooth -- e.g., that have a kink -- are difficult to approximate because the interpolation error estimates require the function being interpolated to be differentiable a number of times. In other words, if you don't like the Weierstrass function too much, you can always just choose $|x|$.
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
add a comment |Â
up vote
8
down vote
It's a pathological case, but you can always resort to the Weierstrass monster function. It illustrates a broader point, namely that functions that are not smooth -- e.g., that have a kink -- are difficult to approximate because the interpolation error estimates require the function being interpolated to be differentiable a number of times. In other words, if you don't like the Weierstrass function too much, you can always just choose $|x|$.
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
add a comment |Â
up vote
8
down vote
up vote
8
down vote
It's a pathological case, but you can always resort to the Weierstrass monster function. It illustrates a broader point, namely that functions that are not smooth -- e.g., that have a kink -- are difficult to approximate because the interpolation error estimates require the function being interpolated to be differentiable a number of times. In other words, if you don't like the Weierstrass function too much, you can always just choose $|x|$.
It's a pathological case, but you can always resort to the Weierstrass monster function. It illustrates a broader point, namely that functions that are not smooth -- e.g., that have a kink -- are difficult to approximate because the interpolation error estimates require the function being interpolated to be differentiable a number of times. In other words, if you don't like the Weierstrass function too much, you can always just choose $|x|$.
answered Sep 6 at 15:28
Wolfgang Bangerth
36.8k3274
36.8k3274
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
add a comment |Â
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
Thanks, this is exactly what I meant by "I thought about something 'noisy'". Very good example IMO.
â Laryx Decidua
Sep 7 at 12:47
add a comment |Â
up vote
6
down vote
Approximation is not only made hard by the function to be approximated but by the interval in which the approximation should be a "good fit". And you should define the measure for a "good fit", i.e. what is the maximum (absolute or relative) error you wish to tolerate?
For example, you will need a huge number of terms in the Taylor series of $exp(x)$ to have a reasonable fit on the interval $[0,10]$. The same holds for periodic functions. Take $sin(x)$, for example, on the interval $[0,2pi]$. See pictures below...
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
add a comment |Â
up vote
6
down vote
Approximation is not only made hard by the function to be approximated but by the interval in which the approximation should be a "good fit". And you should define the measure for a "good fit", i.e. what is the maximum (absolute or relative) error you wish to tolerate?
For example, you will need a huge number of terms in the Taylor series of $exp(x)$ to have a reasonable fit on the interval $[0,10]$. The same holds for periodic functions. Take $sin(x)$, for example, on the interval $[0,2pi]$. See pictures below...
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
add a comment |Â
up vote
6
down vote
up vote
6
down vote
Approximation is not only made hard by the function to be approximated but by the interval in which the approximation should be a "good fit". And you should define the measure for a "good fit", i.e. what is the maximum (absolute or relative) error you wish to tolerate?
For example, you will need a huge number of terms in the Taylor series of $exp(x)$ to have a reasonable fit on the interval $[0,10]$. The same holds for periodic functions. Take $sin(x)$, for example, on the interval $[0,2pi]$. See pictures below...
Approximation is not only made hard by the function to be approximated but by the interval in which the approximation should be a "good fit". And you should define the measure for a "good fit", i.e. what is the maximum (absolute or relative) error you wish to tolerate?
For example, you will need a huge number of terms in the Taylor series of $exp(x)$ to have a reasonable fit on the interval $[0,10]$. The same holds for periodic functions. Take $sin(x)$, for example, on the interval $[0,2pi]$. See pictures below...
edited Sep 6 at 15:48
nicoguaroâ¦
4,00441131
4,00441131
answered Sep 6 at 14:01
GertVdE
4,7591332
4,7591332
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
add a comment |Â
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
I show such examples in my course to make the point that Taylor expansion is not a good method to approximate functions.
â Praveen Chandrashekar
Sep 7 at 16:16
add a comment |Â
up vote
4
down vote
Polynomials are surprisingly effective at function approximation [1]. If you have at least Lipschitz continuity, then Chebyshev approximations will converge. Of course, convergence may be slow, and that is the price we pay for dealing with a non-smooth function.
Today, computers are much faster than the days in which many numerical analysis books were written, and clever algorithms have increased the speed further, so that having to use more terms may not be as bad as it used to be.
The pathological examples like Weierstrass monster function are interesting from a theoretical point of view, but they are not representative of most real application contexts.
I think we should be careful not to give a pessimistic view to our students. Ok, there is no method that works for all problems. But we can build adaptive methods, say even based on polynomials, that can deal with such cases. For example, Chebfun [2] can easily approximate $|x|$ by automatically splitting the domain at $x=0$.
It is important to teach the difficulties in approximation with polynomials, but it also important to tell the students that we can build error estimates and adaptive algorithms that can deal with these issues.
[1] https://people.maths.ox.ac.uk/trefethen/mythspaper.pdf
[2] http://www.chebfun.org
add a comment |Â
up vote
4
down vote
Polynomials are surprisingly effective at function approximation [1]. If you have at least Lipschitz continuity, then Chebyshev approximations will converge. Of course, convergence may be slow, and that is the price we pay for dealing with a non-smooth function.
Today, computers are much faster than the days in which many numerical analysis books were written, and clever algorithms have increased the speed further, so that having to use more terms may not be as bad as it used to be.
The pathological examples like Weierstrass monster function are interesting from a theoretical point of view, but they are not representative of most real application contexts.
I think we should be careful not to give a pessimistic view to our students. Ok, there is no method that works for all problems. But we can build adaptive methods, say even based on polynomials, that can deal with such cases. For example, Chebfun [2] can easily approximate $|x|$ by automatically splitting the domain at $x=0$.
It is important to teach the difficulties in approximation with polynomials, but it also important to tell the students that we can build error estimates and adaptive algorithms that can deal with these issues.
[1] https://people.maths.ox.ac.uk/trefethen/mythspaper.pdf
[2] http://www.chebfun.org
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Polynomials are surprisingly effective at function approximation [1]. If you have at least Lipschitz continuity, then Chebyshev approximations will converge. Of course, convergence may be slow, and that is the price we pay for dealing with a non-smooth function.
Today, computers are much faster than the days in which many numerical analysis books were written, and clever algorithms have increased the speed further, so that having to use more terms may not be as bad as it used to be.
The pathological examples like Weierstrass monster function are interesting from a theoretical point of view, but they are not representative of most real application contexts.
I think we should be careful not to give a pessimistic view to our students. Ok, there is no method that works for all problems. But we can build adaptive methods, say even based on polynomials, that can deal with such cases. For example, Chebfun [2] can easily approximate $|x|$ by automatically splitting the domain at $x=0$.
It is important to teach the difficulties in approximation with polynomials, but it also important to tell the students that we can build error estimates and adaptive algorithms that can deal with these issues.
[1] https://people.maths.ox.ac.uk/trefethen/mythspaper.pdf
[2] http://www.chebfun.org
Polynomials are surprisingly effective at function approximation [1]. If you have at least Lipschitz continuity, then Chebyshev approximations will converge. Of course, convergence may be slow, and that is the price we pay for dealing with a non-smooth function.
Today, computers are much faster than the days in which many numerical analysis books were written, and clever algorithms have increased the speed further, so that having to use more terms may not be as bad as it used to be.
The pathological examples like Weierstrass monster function are interesting from a theoretical point of view, but they are not representative of most real application contexts.
I think we should be careful not to give a pessimistic view to our students. Ok, there is no method that works for all problems. But we can build adaptive methods, say even based on polynomials, that can deal with such cases. For example, Chebfun [2] can easily approximate $|x|$ by automatically splitting the domain at $x=0$.
It is important to teach the difficulties in approximation with polynomials, but it also important to tell the students that we can build error estimates and adaptive algorithms that can deal with these issues.
[1] https://people.maths.ox.ac.uk/trefethen/mythspaper.pdf
[2] http://www.chebfun.org
edited Sep 8 at 13:37
Anton Menshov
2,99221255
2,99221255
answered Sep 8 at 3:09
Praveen Chandrashekar
794410
794410
add a comment |Â
add a comment |Â
up vote
2
down vote
$f(x) = frac1x^2+1$ has this Maclaurin series expansion:
$frac1x^2+1 = 1-x^2+x^4-x^6+x^8-x^10+x^12 - ldots$
This converges for $-1<x<1$, but it diverges everywhere else. A polynomial approximation around $x=0$ will never get you anywhere near the right answer for $x=2$.
New contributor
add a comment |Â
up vote
2
down vote
$f(x) = frac1x^2+1$ has this Maclaurin series expansion:
$frac1x^2+1 = 1-x^2+x^4-x^6+x^8-x^10+x^12 - ldots$
This converges for $-1<x<1$, but it diverges everywhere else. A polynomial approximation around $x=0$ will never get you anywhere near the right answer for $x=2$.
New contributor
add a comment |Â
up vote
2
down vote
up vote
2
down vote
$f(x) = frac1x^2+1$ has this Maclaurin series expansion:
$frac1x^2+1 = 1-x^2+x^4-x^6+x^8-x^10+x^12 - ldots$
This converges for $-1<x<1$, but it diverges everywhere else. A polynomial approximation around $x=0$ will never get you anywhere near the right answer for $x=2$.
New contributor
$f(x) = frac1x^2+1$ has this Maclaurin series expansion:
$frac1x^2+1 = 1-x^2+x^4-x^6+x^8-x^10+x^12 - ldots$
This converges for $-1<x<1$, but it diverges everywhere else. A polynomial approximation around $x=0$ will never get you anywhere near the right answer for $x=2$.
New contributor
New contributor
answered Sep 7 at 8:35
Christopher Wells
212
212
New contributor
New contributor
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fscicomp.stackexchange.com%2fquestions%2f30157%2fexample-of-a-continuous-function-that-is-difficult-to-approximate-with-polynomia%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password