Adapting Unwrapping Techniques for Plotting Phase Values

  • Context: Mathematica 
  • Thread starter Thread starter Swamp Thing
  • Start date Start date
  • Tags Tags
    Phase Plot
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
Swamp Thing
Insights Author
Messages
1,062
Reaction score
819
TL;DR
Plotting Arg[ f[x] ] gives output that has jumps of +/- 2Pi and is limited to +-Pi.
Can we unwrap this into a jumpless plot?
This discussion https://community.wolfram.com/groups/-/m/t/1340126 includes some ideas to unwrap a list of wrapped-around values such as phase (e.g. Arg[ f[N] ] ). You can use this to ListPlot a jump-free graph.

I'm trying to adapt this to work in Plot rather than ListPlot. The idea is to plot fnUnwrap [ myPhase[t] ], where fnUnwrap is called whenever the plotter wants to evaluate the Y value.

Now fnUnwrap needs to use two successive phase values, and also maintain a cumulative total of all the jumps. So we store some "state information" in the variables unwrap`old and unwrap`cumu, i.e. the previous input and the accumulated jumps. Here is my attempt:
Code:
fnUnwrap2[new_,\[CapitalDelta]_,tol_]:=Module[{jmp},
                                    jmp=new-unwrap`old;
                                    jmp=-Sign[jmp] Unitize[        Chop [ Abs[jmp],tol      ]   ];
                                    jmp= jmp *  \[CapitalDelta];
                                    unwrap`cumu=unwrap`cumu+jmp;
                                    unwrap`old=new;
                                    new + unwrap`cumu
                                                                                  ]

This code "sort of" works, but has these spikes around the jump points and has an offset as well:

Code:
unwrap`old=0
unwrap`cumu=0

Plot[{ fnUnwrap2[Mod[ x, 2],2,1.75],
           x
        
    },{x,0,12},PlotRange->All,PlotPoints->250]

Output:
1635757404617.png


Can this be fixed , or is there a better approach?
 
Last edited:
Physics news on Phys.org
Perhaps part of the problem is that the plotting algorithm often evaluates Arg[f[x]] in a random sequence of X. Maybe we need to store not only old_Arg but also old_X, and somehow use that to avoid confusing the plotting algorithm.

Any suggestions much appreciated.
 
Last edited: