Order of polynomial display: increasing order of powers?
古いコメントを表示
A symbolic polynomial will be displayed in order of decreasing powers:
>> taylor(sin(x),x,'Order',11)
ans =
x^9/362880 - x^7/5040 + x^5/120 - x^3/6 + x
Is there a preference value I can set which will display such polynomials in increasing order of powers? Like this:
x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880
Thank you!
4 件のコメント
Karan Gill
2016 年 10 月 27 日
Why do you need this particular ordering? Details on what you are trying to do would be helpful.
Walter Roberson
2016 年 10 月 27 日
The order is important because it is a taylor expansion and the classic representation of a taylor expansion is in increasing orders of differentiation, which for sin() and a number of other important functions results in increasing powers of x.
The order of the terms should be in increasing n so that one can quickly see the effect of truncating at some lower point and so that one can quickly see the pattern in the coefficients.
HiWave
2020 年 2 月 18 日
I find this extremely annoying as well. It is as if they anticipate no practical use of the output.
Bilal Akbana
2021 年 4 月 29 日
Following command works and gives result as shown below;
syms x
sympref('PolynomialDisplayStyle','ascend');
sinTaylor = taylor(sin(x),x,'Order',11);
disp(sinTaylor)
x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880
採用された回答
その他の回答 (1 件)
Robert
2016 年 10 月 26 日
Hey there
So this is a bug in matlab I found the bug a few weeks ago and it should be fixed in the next release
It turns out with the addition of a tilda you can change the order in which the coeffs function returns values.
Try the following code and please don't forget to accept the answer so i can get the credit for helping. Thanks!
syms x
y = x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880
[High_Order , ~] = coeffs(y) % Use this to get the higher order first
Coefficient_Low_first = coeffs(y)
4 件のコメント
Alasdair McAndrew
2016 年 10 月 26 日
Robert
2016 年 10 月 26 日
You obviously did not try my code I just showed you how to do exactly this. Adding the brackets and the tilda changes the order.
Its a bug in matlab that i have previously reported
The output is as follows. If you tried what i gave you your issue would be solved
>> T = taylor(sin(x),x,'Order',10);
>> coeffs(T)
ans =
[ 1, -1/6, 1/120, -1/5040, 1/362880]
>> [T,~]=coeffs(T)
T =
[ 1/362880, -1/5040, 1/120, -1/6, 1]
>>
Walter Roberson
2016 年 10 月 26 日
You can extract the coefficients in one order or the reverse but the user needs the symbolic expression itself to be displayed in a different order
Walter Roberson
2016 年 10 月 26 日
Consider for example sin() around the expression. coeffs() would not work because that would not be a multinomial, but you might still have an interest in the order that the expression displays.
カテゴリ
ヘルプ センター および File Exchange で Polynomial Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!