1
$\begingroup$

My question is not really related to Mathematica; however, I put it in a way that uses Mathematica, so perhaps someone could help here.

I'm given a set of data as

data = {{4, 0.96}, {8, 1.06}, {16, 1.61}, {31, 1.98}, {63, 3.03}, {125, 4.75}, {250, 8.35}, {500, 13.33}}

and asked to reproduce the following plot:

enter image description here

This can be done as follows:

logdata = {Log[2, #[[1]]], #[[2]]} & /@ data;

ListLinePlot[logdata, PlotMarkers -> {Graphics[{Disk[], {Thick, Circle[]}}], 0.04}, Ticks -> {{{2, 4}, {3, 8}, {4, 16}, {5, 31}, {6, 63}, {7, 125}, {8, 
 250}, {9, 500}}, {2, 4, 6, 8, 10, 12, 14}}]

Now, I'm asked to get the first two points in the above, i.e., $(4, 0.96)$ and $(8, 1.06)$, and to extrapolate linearly and obtain the corresponding $y$ values for $x = 16, 31, 63, 125, 250, 500$.

To this end, first we calculate the slope as $m = (y_2 - y_1)/(x_2 - x_1) = 0.025$ and then we have:

y[x_] := 0.96 + 0.025 (x - 4)

So, for example, for $x = 500$, we have: $y = 13.36$. But this doesn't seem to be correct! The result should be much less than this. What I'm missing here? Does this has something to do with the scale of $x$-axis and I've neglected something? What is the correct approach for linear extrapolation in this case?

$\endgroup$
1
  • $\begingroup$ Are you meant to be extrapolating the log data or the data that has not been logged? $\endgroup$
    – Hugh
    Nov 13, 2022 at 21:04

2 Answers 2

2
$\begingroup$

Without considering logs, the extrapolation looks ok.

data = {{4, 0.96}, {8, 1.06}, {16, 1.61}, {31, 1.98},
   {63, 3.03}, {125, 4.75}, {250, 8.35}, {500, 13.33}};
y[x_] := 0.96 + 0.025 (x - 4)
ListPlot[{data, {#, y[#]} & /@ {16, 31, 63, 125, 250, 500}}]

Taking logs

logdata = {Log[2, #[[1]]], #[[2]]} & /@ data;
logdata2 = {Log[2, #[[1]]], #[[2]]} & /@ Map[{#, y[#]} &,
    {16, 31, 63, 125, 250, 500}];

ListLinePlot[{logdata, logdata2},
 PlotMarkers -> {Graphics[{Disk[], {Thick, Circle[]}}], 0.04}, 
 Ticks -> {{{2, 4}, {3, 8}, {4, 16}, {5, 31}, {6, 63}, {7, 125},
    {8, 250}, {9, 500}}, {2, 4, 6, 8, 10, 12, 14}}]
$\endgroup$
0
2
$\begingroup$

I also see nothing wrong with 13.36

data = {{4, 0.96}, {8, 1.06}, {16, 1.61}, {31, 1.98}, {63, 
    3.03}, {125, 4.75}, {250, 8.35}, {500, 13.33}};
m = (data[[2, 2]] - data[[1, 2]])/(data[[2, 1]] - data[[1, 1]]);
y[x_] := data[[1, 2]] + m (x - data[[1, 1]]);
y[500]
(* 13.36*)

Proof:

Show[ListLinePlot[data, Mesh -> All, PlotStyle -> Gray], 
 Plot[y[x], {x, 0, 500}, PlotStyle -> Red]]

Mathematica graphics

logdata is not even used or relevant. So why it is included in the question?

$\endgroup$

Your Answer

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