argument vector for smooth function plots

조회 수: 4 (최근 30일)
Ilya
Ilya 2014년 3월 19일
편집: Ilya 2014년 5월 3일
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
Ilya
Ilya 2014년 3월 20일
편집: Ilya 2014년 3월 20일
I suspect that the derivatives could be used somehow, but I don't no how to use them in a good way...
Ilya
Ilya 2014년 3월 20일
편집: 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
Ilya 2014년 3월 20일
편집: Ilya 2014년 5월 1일
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.
THE ANSWER:
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
John D'Errico
John D'Errico 2014년 5월 2일
편집: John D'Errico 2014년 5월 3일
You THINK this is a reasonable thing to do, to work with high order polynomials in double precision. However, one day you will realize that you were kidding yourself.
Sorry, but working with polynomials of that high of an order (20-30) in double precision is a foolish thing to do in general. You MAY be successful with lower orders, depending on the domain of interest.
I see that you accepted your own answer, so you clearly know everything already.
Ilya
Ilya 2014년 5월 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
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
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by