# taylor series of expression involving modulus of a complex expression

Consider the following

```
sage: w = SR.var('w')
sage: a = -cos(w)^2 + 2*I*cos(w)*sin(w) + sin(w)^2 + 2.8*cos(w) - 2.8*I*sin(w) - 1.8
sage: b = abs(a)
sage: b.taylor(w, 0.1, 1) # not the answer I expected!
-(0.8150178993589604 + 0.178042614591617*I)*w
+ 0.16258427059001673 + 0.0178042614591617*I
sage: c = sqrt(b.real()**2 + b.imag()**2)
sage: c.taylor(w, 0.1, 3) # works as expected!
1.002855497443298*(w - 0.1)^3
+ 0.3184495453305423*(w - 0.1)^2
+ 0.8322931797904074*w
- 0.002146837324920048
```

So as you can see I have two mathematically equivalent expressions, `b`

and `c`

,
but Sage is not able to directly find the Taylor series of the first.

Is there a way to convince Sage to do this correctly?

I'm not sure that your question has a meaning (I'm not able to understand it). Consider :

What do you mean ?

Thanks for the response Emmanuel - now I am confused!! Another user came in and edited my question to make it look nicer but certainly I get a different result!

Here is my original source: w=SR.var('w') tt=abs(-cos(w)^2 + 2

Icos(w)sin(w) + sin(w)^2 + 2.8cos(w) - 2.8Isin(w) - 1.8) print(tt.taylor(w,0.1,3)) print("") ttt=-cos(w)^2 + 2Icos(w)sin(w) + sin(w)^2 + 2.8cos(w) - 2.8Isin(w) - 1.8 lttt=sqrt(ttt.real()2+ttt.imag()2) print(lttt.taylor(w,0.1,3))and output:

-(77.5983311918384 + 60.00589446569399

I)(w - 0.1)^3 - (8.236463209769601 + 3.57404233017743I)(w - 0.1)^2 - (0.8150178993589604 + 0.178042614591617I)w + 0.16258427059001673 + 0.0178042614591617*I1.002855497443298

(w - 0.1)^3 + 0.3184495453305423(w ...(more)Tip: indent code fragments by four spaces so they display properly.

Your "original code" didn't make it through this editor's markup. I guessed :

Can you confirm ? If so, it turns out that

You seem to expect that

`ttt`

and`ttt.abs()`

have the same Taylor development. It ain't necessarily so...Simple illustrative counter-example : see my answer