# argument vector for smooth function plots

2 ビュー (過去 30 日間)
Ilya 2014 年 3 月 19 日

Hello,
I have arbitrary polynomial functions y=f(x) of a degree, say, N<30 and need to plot them over some predefined interval of x. Is it possible to choose the vector of x so that this particular type of function (i.e. polynomials) is plotted "smoothly", i.e. that there's no big accuracy differences between the intervals of a large slope and small slope of y?
If I simply choose x with some constant step, then some parts of the curve will be very accurate while the others will be inaccurate.
An expert opinion is also valuable because the speed is an issue, i.e. it's better not to call the diff function 1000 times, if possible.
##### 2 件のコメント表示非表示 1 件の古いコメント
Ilya 2014 年 3 月 20 日
The problem is also not about data interpolation, i.e. splines are not the solution. And the 30th degree is only an example for "high degree". In fact, the degree of polynomials can be constrained to a realistic value, if needed.

サインインしてコメントする。

### 採用された回答

Ilya 2014 年 3 月 20 日

No, I'm quite sane. The degree of 30 is only an example of a high degree. Normally, the degree is 4-15, at max. 20.
If there are some precision problems due to high polynomial orders, then the max. order can be constrained (I hope the orders of 4-10 are still manageable in double..).
My problem is also not about data interpolation (i.e. splines are not considered). I'm really concerned that some important parts of a curve may be skipped during the plotting, if an unreasonable argument vector is selected. The "plotting" happens automatically into a file, so I don't have the visual control of the results.
Differentiate the polynomial (polyder) and find the zeros of the derivative (roots). These zeros will be the critical points for the plot, take all other sample points between them.
Polynomial rootfinding and evaluation can be performed in Chebyshev basis instead of the "calssical" monomial/power one. See Clenshaw algorithm for polynomials in Chebyshev basis. The accuracy in Chebyshev basis is typically higher then of the monomial one. Alternatively, use precision better then double..
##### 4 件のコメント表示非表示 3 件の古いコメント
Ilya 2014 年 5 月 3 日
Dear John,
I don't think anything. I only said that it's possible to make the problem better conditioned by using the Chebyshev basis. Then it might be possible to work in double with slightly higher polynomial orders. As for orders, I'm using Advanpix Multiprecision Computing Toolbox (I said this in the initial problem formulaton, but then removed), which has the fast quadruple precision mode. Anyway, I need to use moderately high order polynomials, and not for the purpose of interpolation.
As for the rest of the methodology, finding extrema and plotting between them seems to be the only sane alternative. And I "accepted" long ago that "No, I'm quite sane", "the answer" addition came much later.
I'm sad to write this... I know nothing and I'm stupid that's why I never write about other people that they're insane (although, I know why you did this.. don't worry and nevermind, I understand it)

サインインしてコメントする。

### その他の回答 (1 件)

John D'Errico 2014 年 3 月 20 日
Use of 30'th degree polynomials is insane, at least in double precision. Period. INSANE.
If you are worried about accuracy, perhaps there is a reason why. Oh, that is right, you are using insanely high order polynomials.
Learn to use splines instead. Regain some degree of sanity.
##### 1 件のコメント表示非表示 なし
Ilya 2014 年 3 月 20 日
Is it a suggestion to use splines instead of high order polynomials for interpolation (if so, my problem is for sure not in interpolation), or do you mean that splines have some other usages that сan be helpful here?

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by