# How to do a Taylor expansion with a matrix

25 ビュー (過去 30 日間)
kuroshiba 2023 年 5 月 26 日
コメント済み: Paul 2023 年 6 月 1 日
I have tried the official matlab website that describes the Taylor expansion, but it doesn't work!
G = [0,4;4,0];
T = taylor(exp(G));
error message "Function 'taylor' (input argument of type 'double') is undefined."
I would like to know the result of infinite convergence separately.
I would be glad if you could tell me!
##### 2 件のコメントなしを表示なしを非表示
Ashutosh 2023 年 5 月 26 日
I am not sure I understand your query. A Taylor expansion can be constructed for a function of some variable x. What you are feeding into the Taylor function taylor(), seems to be a constant. You can't have a Taylor expansion, approximation or anything for a constant.
kuroshiba 2023 年 6 月 1 日
I see, I had mistakenly thought that Taylor expansion could be done with constants!

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

### 採用された回答

Torsten 2023 年 5 月 26 日

Maybe you mean:
G = [0,4;4,0];
Gexp = expm(G)
Gexp = 2×2
27.3082 27.2899 27.2899 27.3082
or
syms t
G = [0,4;4,0]*t;
Gexp = simplify(taylor(expm(G),t,'ExpansionPoint',1))
Gexp =
Gexp = simplify(subs(expm(G),t,1))
Gexp =
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
kuroshiba 2023 年 6 月 1 日
That is what I wanted to know! Thank you!
I'm sorry for the lack of words and understanding that bothered you.

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

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

KSSV 2023 年 5 月 26 日
syms x
f = exp(x)
f =
T = taylor(f)
T =
In place of x substitue each value of G.
##### 0 件のコメント-2 件の古いコメントを表示-2 件の古いコメントを非表示

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

John D'Errico 2023 年 5 月 26 日
You cannot compute the Taylor series of a constant. You CAN compute a Taylor series, and then evaluate it at that constant value, since the truncated series is then a polynomial.
Will only a few terms from that Taylor series be close to yielding a convergent result? This is something you need to consider, and that is a big part of your homework where you have shown no effort. The eigenvalues of G will be an important factor.
G = [0,4;4,0];
eig(G)
ans = 2×1
-4 4
So, given that, will a simple Taylor series for exp(x) converge well for x==4 (or x==-4, for that matter)? How many terms would you expect that to require? Why did I compute the eigenvalues of G here? How are they pertinent?
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Paul 2023 年 6 月 1 日
Isn't the Taylor series of function that's a constant just the constant?
syms f(x)
f(x) = sym(8);
taylor(f(x))
ans =
8

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

### カテゴリ

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

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by