MathStudio  Blog  Share  Manual  Forums  Support 
Bug with real and imaginary parts ?
  • Hello!

    I get something quiute wrong when trying to evaluate the compound of a function (factorized polynomial) with real or imaginary part. I didn't find this topic on the forum, sorry if it has already been posted.

    I try to evaluate Re( ( x + i*y )²). I am obviously expecting x² - y².
    However, returned result is x², while Im( ( x + i*y )²) returns... i y² + 2 xy, which is ot even real.

    Same strange thing happens with cubes - and I didn't go any further testing.

    Re(Expand( ( x + i*y )²)) returns the proper result, though. But, regardless of the wrong calculation, I do find it cumbersome tu use an Expand function each time I have to compute the imaginary or real part of some complex expression - without any guaranty that this truly works in all and every situation.

    This remains a strong impediment to use MathStudio with complex numbers (though it is fine and quite enjoyable with reals). Any fix ahead ?
  • Re and im will only return the numerical real or imaginary part. You want to use Real and Imag for symbolic expressions.
    http://www.mathstudio.net/manual/Real
    http://www.mathstudio.net/manual/Imag
  • Thanks this works. No symbolic evaluation though but I do get the proper result.
  • Hello!

    I'm back. I get strange behaviours with Re and Imag.

    This happens as I am using parametric plot.

    Let f be a complex function of the real variable. The goal is to plot f on the complex plane identified with R², that is as the graph of
    x = re (f)
    y = im (f).

    I therefore used : ParametricPlot([ x, y]).

    My problem is I had to adapt the real part and imaginary part functions to the f function itself.
    Namely : if I wanted to draw the unit circle ( f(x)=exp (ix) ) I had to rely on the Real and Imag functions. But if I wanted to draw a line as f(x) = (1+i)x , I had to use Re and Im instead. I would not get the proper result otherwise.

    I do not exactly understand why. I thought both cases would work with the Real/Imag pair - both "f"s are "expressions" and not "numbers".

    And I do have problems in finding how to generalize this operation for any given "f" which I'd pass as a parameter to some function. Is there a test I should make (as IsNumber, for instance) so as to adapt the call to Re vs Real, Im vs Imag? Could this work? Is this the proper way to proggram it, however riugged it may seem?

    Any idea?

    Thanks for your help!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion