필터 지우기
필터 지우기

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