As a newcomer to Mathematica (V13.2 Home Edition), I encountered an issue that might be due to my misunderstanding of the use of the AbsArg function within the PolarPlot of a complex function. The notebook file shown below compares polar plots of Exp[I [Omega]]. The first plot uses separate Abs and Arg functions, and produces the anticipated results. The second plot uses the AbsArg function, and is inconsistent with the first plot.
My understanding is that the AbsArg function separates abs and arg as elements of a list. Then why do the two plots differ?
Any insight into this behavior is greatly appreciated.
Couple of things going on here. When using the various plotting functions, you need to understand that the “body”, the first argument, is held unevaluated. It’s kept as the sort of template expression that will be evaluated at various points in the specfied range. Then next thing to understand is that the typical behavior of plotting functions when you give them a list is to treat it as multiple, independent plots.
there is only one “thing” in the body, so it thinks it’s going to plot a single plot. That’s why there is only one color in the result. By the way, the {} are superfluous, as AbsArg returns a list. Now, you can force something to evaluate that would otherwise be held. You do this with Evaluate. So, you can reproduce the first plot like this:
Execution of this cell indicates that arg has a constant value (Pi) regardless of the value of omega. Arg is expected to be equal to omega for omega from 0 to Pi/2. What am I missing?
I’m guessing that somewhere you gave a value to omega in the Global context. This is the risk of forcing evaluation. If omega has no value defined for it, then forcing Evaluate is okay, because the evaluation stops at a point where omega appears as just a symbol, and then it will take on the values in the range specifier. But if omega was given a value, then Evaluate will keep going, plugging in that value.
You can sort of protect against this if you use formal symbols: