フィルターのクリア

Get constant term of a symbolic function

6 ビュー (過去 30 日間)
Skye
Skye 2014 年 1 月 15 日
回答済み: Skye 2014 年 2 月 1 日
I want to get the constant term of functions, similar to f = 1/(x*(z-1)) - 1/x^2 + 1/(x*z-1) (constant term is -1 regarding x, -1/x - 1/x^2 - 1 regarding z) Usually you could just set x = 0 and leave out Inf, but in this case there would be Inf - Inf, thus matlab displays NaN.
My best idea would be to extract or delete a single term(for example 1/x^2) and check if it's Inf if x = 0, if so then replace 1/x^2 with 0 (using string replace or regexprep or w.e). However i have yet to extract a single term, using splitstring at an operator (+ / -) would also apply inside the denominator.
I also cannot search for specific strings since the functions are generated using partial fractions in a loop and therefore not really predictable.
  2 件のコメント
Patrik Ek
Patrik Ek 2014 年 1 月 21 日
編集済み: Patrik Ek 2014 年 1 月 21 日
Ok I removed my answer since it did not work out. However, there are one way to work this out that should work. I am not really sure of how you do it in matlab. The real problem is that you have a singularity in 0, which makes taylor expansion (which is otherwise a good way to find a constant term) impossible in this case. However, there are an extension to the Taylor Series called Laurent Series. The laurent series uses cauchys intgral formula to make a general polygon expansion as
... + a_-2*x^-2 + a_-1*x^-1 + a_0 + a_1*x + ...,
by using cauchys integral formula, This solution will in all cases give an approximate answer for all functions and for finite length polynomials, the solution will always be exact. THe higher order the higher accuracy. I write this as a comment since the solution is not implemented.
This method did give the correct constant term for your example, when tested in a program outside matlab.
Skye
Skye 2014 年 2 月 1 日
That would indeed work, just takes too much computational effort for a fairly simple problem; I ended up getting my matlab up to date, so i could use the 'children' function, and set terms that give Inf or -Inf for x -> 0 to 0. Thx for your ideas

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

採用された回答

Skye
Skye 2014 年 2 月 1 日
Answer in the comment above

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by