How can I write the taylor series expansion for the function (1+x^2)^(-1/2) in code

Hello. I am trying to get this taylor series expansion in code but I am having a hard time. I attached a picture of the function and its taylor series expansion. I thought of using the factorial function but I don't think that will work here. Thank you for the help.

2 件のコメント

Geoff Hayes
Geoff Hayes 2018 年 7 月 5 日
Joshua - no, you probably don't need to use the factorial function here. But from what you have shown, what is the pattern? Once you figure that out then the expansion should be easy.
JoshT_student
JoshT_student 2018 年 7 月 5 日
Thank you Geoff.

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

 採用された回答

Torsten
Torsten 2018 年 7 月 5 日
編集済み: Torsten 2018 年 7 月 5 日
a0 = 1
an = -a(n-1) * (2*n-1)/(2*n)

4 件のコメント

JoshT_student
JoshT_student 2018 年 7 月 5 日
Thanks. What is a? And what does n go from?
Torsten
Torsten 2018 年 7 月 5 日
編集済み: Torsten 2018 年 7 月 5 日
Just insert n = 1,2,3,...
a0 = 1
a1 = -1*1/2=-1/2
a2 = 1/2*3/4
a3 = -1/2*3/4*5/6
...
Now you see that the an's are the coefficients of the taylor expansion in front of x^(2*n).
Best wishes
Torsten.
JoshT_student
JoshT_student 2018 年 7 月 5 日
Thank you Torsten, now to get 50 terms of it, I just need to put it in a for loop?
Torsten
Torsten 2018 年 7 月 6 日
x=0.5;
f=1.0;
a=1.0;
xn=1.0;
n=25;
for i=1:n
a=-a*(2*i-1)/(2*i);
xn=xn*x^2;
f=f+xn*a;
end

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

質問済み:

2018 年 7 月 5 日

コメント済み:

2018 年 7 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by