Search code examples
maple

Maple: simplifying Im(a+I*b) - why it does not work for me?


So I want to simplify z:=a+I*b; Im(z) where a, b are real variables So I try:

s:= 1+2*I
Im(s) // outputs 2
z:=a+I*b
Im(z) // outputs  Im(a+I*b)

So I wonder is it any how possible to simplify Im(z) so to get b as output (here we look at general case meaning z could be any complex expression from real values (like a, b, c etc and complex I))?


Solution

  • You didn't tell Maple that a and b were real, so the simplification doesn't work because it doesn't necessarily hold. One way to get what you want is by using the assume command to let it know:

    > s:=1+2*I;
                                     s := 1 + 2 I
    
    > Im(s);
                                           2
    
    > z:=a+I*b;
                                     z := a + b I
    
    > Im(z);
                                      Im(a + b I)
    
    > assume(a,real);
    > assume(b,real);
    > z;
                                       a~ + b~ I
    
    > Im(z);
                                          b~