# expanding a given function as a power series?

조회 수: 20(최근 30일)
Michael Vaughan 2020년 9월 26일
편집: Ameer Hamza 2020년 9월 26일
say I have a function, for example f(x)=x^3+2x. I want to know how take an arbitrary function like this, and for each x value supstitute , the expontential function in h. I then want to expand this newly represneted function as a power series in h, as each will equal 1+h+h^2/2+h^3/3+....
Now, I understand it will have an infinite amount of terms, so if there was a way I could pick an integer (say m) such that it only calculates this power series up to the h^m term I think that would be awesome
This is quite a big endevor for me, as I have no programming experience. Could somebody show me how to write this script?? Thank you so much I really appreciate it

댓글을 달려면 로그인하십시오.

### 채택된 답변

Ameer Hamza 2020년 9월 26일
편집: Ameer Hamza 2020년 9월 26일
You need the symbolic toolbox for this problem!
syms x y
f(x) = x^3+2*x;
g = f(exp(y));
g_approx = taylor(g, y, 'Order', 10)
Result
>> g_approx
g_approx =
(3937*y^9)/72576 + (6563*y^8)/40320 + (2189*y^7)/5040 + (731*y^6)/720 + (49*y^5)/24 + (83*y^4)/24 + (29*y^3)/6 + (11*y^2)/2 + 5*y + 3

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!