Curve tolerance between the calculated points
3 views (last 30 days)
Show older comments
In order to plot a curve in MATLAB a set of points is calculated based on some formula. The function FPLOT also supports plotting with some tolerance. Its help says the following about this functionality:
The FPLOT function begins with a minimum step of size (XMAX-XMIN)*TOL.
The step size is subsequently doubled whenever the relative error
between the linearly predicted value and the actual function value is
less than TOL.
So, if I plot a curve based on some expression and with some predefined tolerance TOL, is the error of the line segment approximation between any two calculated points always smaller than TOL?
Sorry, this is not obvious for me.
A confident yes/no answer would suffice, but it's also better to explain the reason and/or give an estimate for the maximal error of approximation of a curve with linear segments if a tolerance algorithm like in FPLOT is used.
4 Comments
John D'Errico
on 6 Feb 2014
To be honest, I was not impressed with the help for fplot. I found it quite a bit confusing as to the purpose of the code, the requirements on the function, and all this even for a highly experienced MATLAB user like me.
Matt J
on 6 Feb 2014
I can delete it (or a forum administrator can do this..) if such excerpts are not allowed.
No, I meant you should provide a link to it so that we can know where to find it and read its full text. It wasn't in the help doc...
Accepted Answer
John D'Errico
on 6 Feb 2014
Edited: John D'Errico
on 6 Feb 2014
No. You cannot know the maximum error of approximation between parts of the curve that were not sampled. I can always give you any simple (and very well behaved) curve, plus a delta function in some spot that will not have been sampled. The error of approximation can then be arbitrarily large, and fplot will never know it.
Of course, the curve I suggested as a counter-example will not be continuous or even differentiable. However, if you want that property and still see fplot "fail" to see that spike, then just add a Gaussian instead of a delta function to the well-behaved function, but choose a Gaussian with an extremely small width. As such, it behaves like a delta function, but is still theoretically infinitely differentiable.
Thus you cannot assure that the error will ALWAYS be smaller than tol, for any supplied tolerance. This is a fundamental issue with virtually any computational algorithm when applied to a completely general function. You can always choose some (locally degenerate) function that will cause it to "fail" to achieve a given tolerance.
3 Comments
John D'Errico
on 6 Feb 2014
Again, consider my counter-case, wherein a linear function plus a narrow Gaussian will result in arbitrarily large errors. The composite function is infinitely differentiable, yet will allow no bounds on the error.
If you choose some set of infinitely differentiable functions (i.e., your trig example) but where the derivatives are LIMITED IN MAGNITUDE ove the domain of interest, then yes you can probably ensure that the tolerance is met.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!