I am trying to plot two functions in one Plot inside a Manipulate-environment. It works fine for "small" ranges of variable and parameter (1...100), but I need it around 5000 or so. When I do this, the plot leaves the visible range of the y-Axis. I tried to use "PlotRange -> Full", but then, upwards of a certain value (about 1000) for my parameter r, the plot suddenly becomes empty.

I guess it has something to do with too large computations, but is there any way to "force" Mathematica to do more / longer computations ... or any other way to plot these functions in a useable way for values of r=5000 and comparable?

My code for the Plot is

Manipulate[Plot[{2^(r(-((Log[Min[r - s, s]/r] Min[r - s, s])/(r Log[2])) - (Log[1 - Min[r - s, s]/r] (1 - Min[r - s, s]/r))/Log[2])), 
   K[2^r - 1]*2^(1/2 r (3/4 - (Log[Min[r - s, s]/r] Min[r - s, s])/(r Log[2]) - (Log[1 - Min[r - s, s]/r] (1 - Min[r - s, s]/r))/Log[2]))}, {s, 1, 5000}, PlotRange -> Full, PlotLegends -> {"L", "RK"}], {r, 1, 

and the function K is defined via

f[x_] := 4.9 x^(1/4);                                                 
g[x_] := 4514.7 x^(1/8);
h[x_] := x^(0.96/(Log[Log[x]]));
K[x_] := Min[f[x], g[x], h[x]]             
  • 1
    $\begingroup$ I tried to run your code, but it is not properly structured. When I tried to fix it, I got the message: "2^(a+bI) is too small to represent as a normalized machine number". So there are likely two problems: underflow (use Chop) and trying to plot a complex number (use Abs). $\endgroup$
    – bill s
    Commented May 7, 2023 at 11:59
  • $\begingroup$ @bills Sorry, it's my first time posting here and I'm unfamiliar with the Code-format options here ... I copied my Code straight out of Mathematica, and some parts went missing. The Manipulate[...] around everything for example .... I added it, and also the definition of the function K i am using. - There are no complex numbers involved, s should be a real variable, and r a real parameter, which I set in the Manipulate environment $\endgroup$ Commented May 7, 2023 at 12:24
  • $\begingroup$ The problem is the numbers are too large. You can get a possibly useful plot by taking the Log of everything... then the y axis has values of (say) 3000 rather than 2^3000. Just do Plot[ Log[{ } ] ] instead of Plot[ { } ] $\endgroup$
    – bill s
    Commented May 7, 2023 at 12:29
  • $\begingroup$ @bills That works great, thank you! Only one last question, because I used PlotLegends to label which function is which, but now both are part of the same "Log" ... how can I make them distinguashable in the Plot? $\endgroup$ Commented May 7, 2023 at 12:38
  • $\begingroup$ It works if you do: Plot[ { Log( ), Log( ) } ] instead of Plot[ Log[{ } ] ]. Note that now you get one blue and one orange (instead of both blue). $\endgroup$
    – bill s
    Commented May 7, 2023 at 12:48

1 Answer 1


(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)


f[x_] := 49/10 x^(1/4);
g[x_] := 45147/10 x^(1/8);
h[x_] := x^((96/100)/(Log[Log[x]]));
K[x_] := Min[f[x], g[x], h[x]]

As pointed out in the comments by bill s, plot the log of the functions. Also, for the lower values of r you probably want to use LogLinearPlot

 min = Min[r - s, s];
 funcs = N[{2^(r (-((Log[min/r] min)/(r Log[2])) - (Log[
             1 - min/r] (1 - min/r))/Log[2])),
    K[2^r - 
       1]*2^(1/2 r (3/
           4 - (Log[min/r] min)/(r Log[2]) - (Log[1 - min/r] (1 - min/r))/
           Log[2]))}, 20];
 plt[Evaluate@Log[funcs], {s, 1, 5000},
  AxesLabel -> (Style[#, 14] & /@ {s, Log}),
  WorkingPrecision -> 15,
  PlotRange -> Full,
  PlotLegends -> {"L", "RK"}],
 {{plt, Plot, "type of plot"}, {Plot, LogLinearPlot}},
 {{r, 2000}, 25, 5000, 25, Appearance -> "Labeled"},
 SynchronousUpdating -> False,
 TrackedSymbols :> {plt, r}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.