4
$\begingroup$

I tried following command and it worked well (you can see the function is positive).

Plot[1 - x^(2^(n + 1)^a - 2^n^a) /. {a -> 1 - 1/10, x -> 1 - 4^(-30)}, {n, 85, 98}, WorkingPrecision -> 100]

But, I couldn't plot Log of this function:

Plot[Log[1 - x^(2^(n + 1)^a - 2^n^a)] /. {a -> 1 - 1/10, x -> 1 - 4^(-30)}, {n, 85, 98}, WorkingPrecision -> 100]

This shows only axes. I tried LogPlot, but it fails as well:

LogPlot[1 - x^(2^(n + 1)^a - 2^n^a) /. {a -> 1 - 1/10, x -> 1 - 4^(-30)}, {n, 85, 98}, WorkingPrecision -> 100]

Why Mathematica can't show log of this function?

$\endgroup$
  • $\begingroup$ The above is done in Mathematica 11.1. I tried in Mathematica 10.4, then LogPlot showed something but wrong. This function must vanish as x decrease but LogPlot showed that it approaches to 1 (Plot[1 - x^(2^(n + 1)^a - 2^n^a)] showed vanishing property). $\endgroup$ – selpo Jul 8 '17 at 8:48
  • $\begingroup$ If I replace Log by RealExponent, it works. (RealExponent[..] is equivalent to Log[Abs[..]], though.) $\endgroup$ – Michael E2 Jul 8 '17 at 19:32
3
$\begingroup$
$Version

(*  "11.1.1 for Mac OS X x86 (64-bit) (April 18, 2017)"  *)

Use Rationalize

Clear[f]

f[n_, prec_: 25] := 
 Module[{rn = Rationalize[n, 0]}, 
  N[1 - x^(2^(rn + 1)^a - 2^rn^a) /. {a -> 1 - 1/10, x -> 1 - 4^(-30)}, prec]]

f[90.1]

(*  0.07970588475709084543825009  *)

Plot[f[n], {n, 85, 98}]

enter image description here

LogPlot[f[n], {n, 85, 98}]

enter image description here

$\endgroup$
  • $\begingroup$ It's a very simple but smart solution! $\endgroup$ – selpo Jul 8 '17 at 14:11
3
$\begingroup$

In Mathematica 10.1.0 LogPlot works:

LogPlot[1 - x^(2^(n + 1)^a - 2^n^a) /. {a -> 1 - 1/10, x -> 1 - 4^(-30)},
  {n, 85, 98}, WorkingPrecision -> 100]

enter image description here

Plot however returns empty:

Plot[Log[1 - x^(2^(n + 1)^a - 2^n^a)] /. {a -> 1 - 1/10, x -> 1 - 4^(-30)},
  {n, 85, 98}, WorkingPrecision -> 100]

enter image description here

A work-around is Table and ListLinePlot:

ListLinePlot[
  Table[Log[1 - x^(2^(n + 1)^a - 2^n^a)] /. {a -> 1 - 1/10, x -> 1 - 4^(-30)},
    {n, 85`100, 98`100}],
  DataRange -> {85, 98}
]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks! This problem seems to be very sensitive to the implementation of Mathematica. Plot and LogPlot does not use the same method of evaluation. $\endgroup$ – selpo Jul 8 '17 at 13:05
3
$\begingroup$
fun = 1 - x^(2^(n + 1)^a - 2^n^a) /. {a -> 1 - 1/10, x -> 1 - 4^(-30)}

enter image description here

For real n this monster formula returns Indeterminate:

Table[Log @ N[fun, 5], {n, 85, 98, 0.5}] // Short

{Indeterminate, ..., Indeterminate}

But it produces results for integer and rational n:

Table[N[Log @ fun, 3], {n, 85, 98, 1/4}] // Short

enter image description here

which you can display with ListLinePlot

ListLinePlot @ Table[Log @ fun, {n, 85, 98, 1/4}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks a lot! Oh, this formula needs too big precision. I decided to use Round[n, 1/100] instead of n. $\endgroup$ – selpo Jul 8 '17 at 13:02
0
$\begingroup$

Here is an approach that works equally in versions 11.1 and 11.0:

Plot[Log[SetPrecision[
    1 - x^(2^(n + 1)^a - 2^n^a), $MachinePrecision] /. {a -> 1 - 1/10,
     x -> 1 - 4^(-30)}], {n, 85, 98}]

I wrapped the original function in SetPrecision, which also allows me to omit the original WorkingPrecision option, so I think this is the simplest solution.

This also works with LogPlot.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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