RE: complex analysis problem in mathematica 3.0

*To*: mathgroup at smc.vnet.net*Subject*: [mg48476] RE: [mg48459] complex analysis problem in mathematica 3.0*From*: "David Park" <djmp at earthlink.net>*Date*: Tue, 1 Jun 2004 03:02:51 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

You can't use j. Use the Mathematica I. step1 = 1/(s^3 + 2*s^2 + 2*s + 1) /. s -> I*w Then you can separate into real and imaginary parts by using ComplexExpand. step2 = ComplexExpand[step1] 1/((1 - 2*w^2)^2 + (2*w - w^3)^2) - (2*w^2)/((1 - 2*w^2)^2 + (2*w - w^3)^2) + I*(-((2*w)/((1 - 2*w^2)^2 + (2*w - w^3)^2)) + w^3/((1 - 2*w^2)^2 + (2*w - w^3)^2)) But how do we further simplify that? We can't use Simplify or Together on the entire expression because that mixes the real and imaginary parts together again. We can get a partial simplification by mapping Simplify onto the parts. step3 = Simplify /@ step2 1/(1 + w^6) - (2*w^2)/(1 + w^6) + (I*w*(-2 + w^2))/ (1 + w^6) But the expression could be further simplified by using Together on the first two terms. Unfortunately Mathematica doesn't provide any direct method of doing that other than resorting to a rule that duplicates the parts on the lhs. I think that Mathematica needs an additional routine that would complement MapAt. I call it MapLevelParts and it maps a function to a subset of level parts in an expression. The common application would be to a subset of terms in a Plus expression or a subset of factors in a Times expression. MapLevelParts::usage = "MapLevelParts[function, {topposition, levelpositions}][expr] will map \ the function onto the selected level positions in an expression. \ Levelpositions is a list of the selected parts. The function is applied to \ them as a group and they are replaced with a single new expression. Other \ parts not specified in levelpositions are left unchanged.\nExample:\na + b + \ c + d + e // MapLevelParts[f, {{2,4,5}}] -> a + c + f[b + d + e]"; MapLevelParts[func_, part : {toppart___Integer?Positive, subp : {_Integer?Positive, eprest__Integer?Positive}}][expr_] := Module[{work, subparts, npos, null, i, nnull = Length[{eprest}]}, work = func@Part[expr, Sequence @@ part]; subparts = Thread[{toppart, subp}]; newparts = {work, Table[null[i], {i, 1, nnull}]} // Flatten; npos = Partition[Range[nnull + 1], 1]; ReplacePart[expr, newparts, subparts, npos] /. null[_] -> Sequence[] ] Now we can use Together on just the first two terms of the sum. step3 // MapLevelParts[Together, {{1, 2}}] (1 - 2*w^2)/(1 + w^6) + (I*w*(-2 + w^2))/(1 + w^6) David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: BranasMan [mailto:branasREmoVe at mail.inet.hr] To: mathgroup at smc.vnet.net i have a complex function: H(s)=1 / (s^3 + 2s^2 + 2s + 1) whan i replace "s" with j*w (j=sqrt(-1)) i get: H=1 / (1 + j2w -2w^2 - jw^3) i would like to get that function in shape of : H=something + j*something_else i.e. the complex and real part apart. i played with Re and Im,but it seems that the fact that "w" is a variable confuses mathematica?! i would reeeealy appreciate any help,and maybe perhaps some links for me to learn to use mathematica better.

**Follow-Ups**:**Re: RE: complex analysis problem in mathematica 3.0***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>