Why is MATLAB not giving me the correct Maclaurin polynomial?

1 回表示 (過去 30 日間)
William Choo
William Choo 2019 年 5 月 28 日
コメント済み: William Choo 2019 年 5 月 28 日
I am trying to evaluate the 4th degree Maclaurin polynomial of the function below using MATLAB:
Capture.PNG
The following code is the one I used in ,
Capture.PNG
But clearly this is not the same answer to the one I computed manually by hand. I obtained the 4th degree Maclaurin Polynomial to be:
Capture.PNG

採用された回答

John D'Errico
John D'Errico 2019 年 5 月 28 日
Lets look at what you did.
If you view this as the exponential function, applied to x^2, thus exp(x^2), we can use the standard Taylor series. That is,
exp(u) = 1 + u + u^2/2 + u^3/6 + u^4/24 + ...
Now, substitute u=x^2, and we have
exp(x^2) = 1 + x^2 + x^4/2 + x^6/6 + x^8/24 + ...
It looks like what you expected. So, you would be correct. Except that you need to read the help for taylor.
What happens in MATLAB?
syms x
taylor(exp(x^2),'order',4)
ans =
x^2 + 1
taylor(exp(x^2),'order',5)
ans =
x^4/2 + x^2 + 1
In the help for taylor, we see:
'Order' Compute the Taylor polynomial approximation with
order n-1, where n has to be a positive integer. The
default value n=6 is used.
So you passed in n=4. It computed a Taylor series approximation of order 3. Yes, I know, the words order and degree are sometimes used as synonyms in mathematics, but then sometimes we see order=degree+1.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by