フィルターのクリア

Transforming from Maclaurin to Taylor

4 ビュー (過去 30 日間)
Angus Wong
Angus Wong 2020 年 5 月 15 日
編集済み: Angus Wong 2020 年 5 月 15 日
I have a polynomial function in terms of x, in which the highest power never exceeds 6. This function will look like a Maclaurin Series with finite terms. How to tell Matlab to rewrite this function into a Taylor one, which will express the function in terms of (x-a), where a is a real, positive number?
E.g. Original function: f(x)=x^3+x^2+x+1
Transformed functions:
If a=1, g(x)=(x-1)^3+4*(x-1)^2+6*(x-1)+4
if a=2, g(x)=(x-2)^3+7*(x-2)^2+17*(x-2)+15
and etc.
I tried using rem but it returned an error message, saying that f(x) must be a real value in order to use rem.

採用された回答

William Alberg
William Alberg 2020 年 5 月 15 日
If i understand correctly, your code looks something like this:
syms x
f(x) = x^3 + x^2 + x +1
f(x-1)
f(x-2)
And you want to expand the expressions. This can be done with the expand command:
expand(f(x-1))
>> x^3 - 2*x^2 + 2*x
expand(f(x-2))
>> x^3 - 5*x^2 + 9*x - 5
  3 件のコメント
William Alberg
William Alberg 2020 年 5 月 15 日
Ahh, I completely misunderstood that!
I dont know how to achieve that, since matlab dont like the "k*(x-a)^1" part, and will rewrite it. I can however get the correct "k*(x-a)^n" for n > 1
My (not complete) solution is this:
f(x) = x^3 + x^2 + x +1;
a = 1;
temp = expand(subs(f(x),x,y + a))
g(x) = subs(temp,y,x-a)
>>6*x + 4*(x - 1)^2 + (x - 1)^3 - 2
Angus Wong
Angus Wong 2020 年 5 月 15 日
編集済み: Angus Wong 2020 年 5 月 15 日
I appologise again for my vague wordings - I have no idea what I was typing earlier. Your new solution do help, thanks a lot!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by