Saving evaluation data for future use?

Hello!

I’m somewhat of a novice to Mathematica and was wondering if there is a way to have Mathematica save evaluation data for longer computations. To clarify, I don’t mean saving output data after a function has been evaluated or saving the notebook. Some of the visualizations using ComplexPlot3D can take a couple of days to render and it’s incredibly frustrating to have to re-render the graph because I set the plot range too high or low (just as an arbitrary example). Alternatively, is there a way to have Mathematica manipulate an output (such as expanding the data range) without totally re-evaluating the original cell?

Bailen,

Some of the visualizations using ComplexPlot3D can take a couple of days to render

This suggests that you are likely doing something wrong in the code. If you post code, we can be more helpful on two fronts:

  1. speeding up the code so it plots quickly
  2. saving intermediate results

if saving intermediate results will help, there are ways to do it, however it is impossible to answer that in the abstract without knowing what you are actually trying to do.

If you can’t post the actual code or its too big, it is best to post a simplified example which essentially does the same thing (like a small example that takes 1-2 min to plot)

Regards,

Neil

You can try reducing PlotPoints and setting PerformanceGoal. Using an example from the documentation

ComplexPlot3D[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I}] // AbsoluteTiming // First
(* 0.254582 *)

ComplexPlot3D[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I},
   PlotPoints -> 5,
   PerformanceGoal -> "Speed"] // AbsoluteTiming // First
(* 0.058856 *)

Use the latter to estimate the desired PlotRange and use it in the former.

If PlotRange -> Automatic (the default), then the range may be restricted using heuristics. In that case you can use Show to recover or further restrict the range.

Compare

p = ListPlot[{0.001, 0.7, 0.003, 0.016, 0.013, 0.04, 0.03}]

Show[p, PlotRange -> All]

Show[p, PlotRange -> {0, 0.02}]

You can use Save to save symbolic expression for the plot (p in the above example) and later use Get to read it and use Show to change the PlotRange.

Okay, current example. The code I’m attempting to evaluate is

ComplexPlot3D[(1 - I) Sign[x] Sum[(Sign[x]^(n - 1) Gamma[n, -n Log[Abs[x]]])/(n^n (n - 1)!), {n, 1, 100}], {x, -8 - 8 I, 8 + 8 I}, PlotRange -> {-3, 10}, ColorFunction -> "CyclicReImLogAbs"] 

it’s been running for 3 days. No errors have popped up yet.

From what I can tell the code is fine as it worked in roughly 10 minutes using ComplexPlot and the only change I made was adding the plot range. However as you can see further reducing the accuracy would only made the output blurrier.

Hello Bailen,

the enormous computation time is in my opinion caused by the fact that your calculation uses exact number in an expression with many terms. If the goal is just to visualize the main features of the result, you can use numerical approximations for the expression. I tried the following:

expr = N[(1 - I) Sign[
       x] Sum[(Sign[x]^(n - 1) Gamma[n, -n Log[Abs[x]]])/(n^
           n (n - 1)!), {n, 1, 100}]] // Simplify // Quiet;

Timing[ComplexPlot[Chop[expr], {x, -8 - 8 I, 8 + 8 I}, 
   PlotRange -> {-3, 10}, ColorFunction -> "CyclicReImLogAbs", 
   ImageSize -> Large] // Quiet]

Timing[ComplexPlot3D[Chop[expr], {x, -8 - 8 I, 8 + 8 I}, 
  PlotRange -> {-3, 10}, ColorFunction -> "CyclicReImLogAbs", 
  ImageSize -> Large]]

With this approximate calculation you get a ComplexPlot and a ComplexPlot3D in a short time ( approx 20s on my old machine) which results in very beautiful images but cannot reproduce the ripples outside the center region. You have to decide whether this approximaion is sufficient for you or not.

Regards, Michael

Thank you so much! That will certainly suffice!