B What function satisfies this table?

Click For Summary
The discussion revolves around finding a periodic function that fits a given table of values. Participants debate whether a cosine function is suitable, with some arguing that the data is better represented by a piecewise linear function or an absolute value function. A proposed fit using the cosine function yields specific parameters, but there is contention over its accuracy compared to simpler linear approximations. The conversation highlights the importance of interpreting the data correctly and the challenges of fitting functions to specific points. Ultimately, the thread emphasizes the need for clarity in defining the desired function type, whether exact or approximate.
  • #31
phinds said:
Hm ... I thought MY interpretation was the simplest possible :smile:
"Interpolation". Drawing a straight line between adjacent points is as simple as it gets. None of that cubic spline stuff.
 
Mathematics news on Phys.org
  • #32
jbriggs444 said:
"Interpolation". Drawing a straight line between adjacent points is as simple as it gets. None of that cubic spline stuff.
But straight line IS my interpretation.
 
  • #33
phinds said:
But straight line IS my interpretation.
You do realize that your interpretation is a step function, not a [pair of] straight line(s), right?
 
  • #34
jbriggs444 said:
You do realize that your interpretation is a step function, not a straight line, right?
Of course, but the data does not support a pure straight line. We seem to be talking past each other.
 
  • #35
phinds said:
Of course, but the data does not support a pure straight line. We seem to be talking past each other.
If you graph your proposed solution, it is a set of horizontal line segments, not a pair of straight lines.

Yes, it may be the case that you come from an age where table lookups (sine tables, cosine tables, log tables, square root tables, etc) from the CRC Handbook of Chemistry and Physics are no longer the norm and the idea of linear interpolation to obtain function results not explicitly in a table is not something that you were taught in school.

When I use the word "interpolation", the idea of linear interpolation between a pair of adjacent entries in a printed table is the picture in my mind. This directly translates into drawing a series of lines between adjacent points on a graph, thereby converting a scatter plot into a line graph.

One can convert a scatter plot to a line graph in many ways. But linear interpolation between adjacent points is as simple as it gets.
 
Last edited:
  • #36
We are still talking past each other, perhaps due to differing terminology. Anyway, enough. It is what it is, WHATEVER that is :smile:
 
  • Like
Likes PhDeezNutz and Bystander
  • #37
phinds said:
We are still talking past each other, perhaps due to differing terminology. Anyway, enough. It is what it is, WHATEVER that is :smile:
No it is not differing terminology, the problem is that ## y=10(1+\operatorname{floor}(\operatorname{abs}(2.5-x))) ## does not look like you think it looks like, it looks like this: https://www.desmos.com/calculator/xausftxwn4

The function that looks like what you have in your head is ## y=10(0.5+(\operatorname{abs}(2.5-x))) ##.

Edit: two half-lines may seem like the simplest interpolation, however the OP is very insistent that a correct interpolation must be periodic. That leaves the cosine interpolation as probably the simplest.
 
  • Like
Likes jbriggs444
  • #38
pbuk said:
The function that looks like what you have in your head is ## y=10(0.5+(\operatorname{abs}(2.5-x))) ##.
ACK ! You are obviously right. My use of the floor function DID make it different than what I had in my head and your correction of my equation is excellent. Thanks.
 
  • Like
Likes PhDeezNutz, dlgoff and jbriggs444
  • #39
phinds said:
f(x) = 10 * (1 + floor(abs(2.5-x)))
Thanks but I wanted it to be periodic, like the portion that I showed in the data is a period.
 
  • #40
MevsEinstein said:
Thanks but I wanted it to be periodic, like the portion that I showed in the data is a period.
So if we were to extend the table, row 6 would be a repeat of row 0, right? The cosine solution hits that nicely.
MevsEinstein said:
I was thinking I could use cosine because its maximum is at x=0.
The periodic data actually has a maximum at x=-0.5 (midway between -1 and 0) and a minimum at x=2.5 (midway between 2 and 3).
 
  • #41
jbriggs444 said:
So if we were to extend the table, row 6 would be a repeat of row 0, right? The cosine solution hits that nicely.

The periodic data actually has a maximum at x=-0.5 (midway between -1 and 0) and a minimum at x=2.5 (midway between 2 and 3).
Yes. I tried using the triangle wave, but I couldn't get the numbers to be exact.
 
  • #42
MevsEinstein said:
Thanks but I wanted it to be periodic, like the portion that I showed in the data is a period.
The periodic version of the piecewise linear fit is a triangle wave. These have the general form
$$ y(x)={\frac {4a}{p}}\left|\left(\left(x-\phi\right){\bmod {p}}\right)-{\frac {p}{2}}\right|-c $$
You can see this plotted with appropriate constants here: https://www.desmos.com/calculator/f5ki6smfan

Edit: in the equation above, ## a ## is the amplitude which as @berkman showed is 15 and ## p ## is the period which again we know is 6. The phase ## \varphi ## and constant offset ## c ## can be determined by trial and error.

There is an important lesson here: given a set of points it is possible to fit functions of many forms, so the question "what function generated these points" has many answers. If you want to fit a function to data, first you have to work out what sort of function you want, then you can find the parameters that achieve the best fit.
 
  • Like
Likes jbriggs444
  • #43
pbuk said:
the period which again we know is 6.
That's why I can't find the correct one, I thought the period was 5 :frown: Thanks for the function!
 
  • #44
MevsEinstein said:
That's why I can't find the correct one, I thought the period was 5 :frown: Thanks for the function!
To be fair, the period for the given data could be 5. The triangle wave would have a lower maximum, the same slope and the same minimum.

Fiddling around without much of a plan, I got: ##y\ =\ \frac{\left(4\cdot12.5\right)}{5}\operatorname{abs}\left(\operatorname{mod}\left(\left(x\right),\ 5\right)\ -\ \frac{5}{2}\right)+5##
 
Last edited:
  • #45
MevsEinstein said:
The plot is only a portion of the whole function.
As I said, you still know more than we do.

MevsEinstein said:
from my own analysis
What do the data represent ?
You sure it is exactly one period ?
And what is the remaining portion, exactly ?

##\ ##
 
  • Love
Likes jbriggs444
  • #46
BvU said:
What do the data represent ?
I'll give in. The data represents the change from one composite number that has a unit digit of 7 to another one.

Take a look:
7,17,(27),37,47,(57)...
The change between 27 and 57 is 30.

I finally got the answer! It is ##10|x\mod 5 - \frac{5}{2}|+5##
 
  • #47
MevsEinstein said:
The data represents the change from one composite number that has a unit digit of 7 to another one.
Three problems.

1. No, the data in #1 is not consistent with this pattern. In particular, 97 is not composite.
2. The sequence you describe is not periodic.
3. Seriously, dude. When asked what you are really trying to do, an answer is appropriate. Not prolonged evasion. We are 47 posts deep into an irrelevant tangent based on a misunderstanding that could have been corrected if you'd been forthcoming in response to @BvU in post #9.
Code:
7 17 (27) 37 47 (57) 67 (77) (87) 97 107 (117) 127 137 (147) 157 167 (177) (187) 197 (207) (217) 227 (237)
      xx         30      20   10           30            30            30    10        20    10       20
One would expect this sequence to converge to ... 30, 30, 30, 30, ... with a few 20, 10 and 10, 20 subsequences scattered therein.
 
Last edited:
  • Like
Likes Vanadium 50, BvU and mfb
  • #48
jbriggs444 said:
Three problems.

1. No, the data in #1 is not consistent with this pattern. In particular, 97 is not composite.
2. The sequence you describe is not periodic.
3. Seriously, dude. When asked what you are really trying to do, an answer is appropriate. Not prolonged evasion. We are 47 posts deep into an irrelevant tangent based on a misunderstanding that could have been corrected if you'd been forthcoming in response to @BvU in post #9.
Code:
7 17 (27) 37 47 (57) 67 (77) (87) 97 107 (117) 127 137 (147) 157 167 (177) (187) 197 (207) (217) 227 (237)
      xx         30      20   10           30            30            30    10        20    10       20
One would expect this sequence to converge to ... 30, 30, 30, 30, ... with a few 20, 10 and 10, 20 subsequences scattered therein.
I didn't know what @BvU meant until recently. That's why I answered him late. Sorry for the misconvenience:frown:
 
  • Skeptical
Likes mfb
  • #49
phinds said:
Oh. I did not realize that. I'm seeing things in this thread with long strings of digits in real numbers. I thought that those were rounded off and not exact.
One can get exact values for the cosine model given by @BvU, by inspection.

Using the function ##y=d\cos(ax+b)+c ## and the given data points:

One half a period is 3 units, so ##a=\dfrac{\pi}{3}## as @BvU indicated.

A minimum occurs at ##x=2.5## units, so there is a maximum at ##x=-0.5## units. Therefore, ##b= \dfrac{\pi}{6}## .

##c## should be the easiest of all parameters to get an exact value for. ##c=20## .

Finally, ##\dfrac{\sqrt{3\,}}{2}\, d =10## so that ##d=\dfrac{20}{\sqrt{3\,}}## .
 
  • #50
MevsEinstein said:
I'll give in. The data represents the change from one composite number that has a unit digit of 7 to another one.
This is very disappointing.

jbriggs444 said:
1. No, the data in #1 is not consistent with this pattern. In particular, 97 is not composite.
Absolutely, @MevsEinstein you need to take more care.

jbriggs444 said:
2. The sequence you describe is not periodic.
Absolutely, @MevsEinstein if you suspected a periodic relationship you should have calculated more values.

jbriggs444 said:
3. Seriously, dude. When asked what you are really trying to do, an answer is appropriate. Not prolonged evasion. We are 47 posts deep into an irrelevant tangent based on a misunderstanding that could have been corrected if you'd been forthcoming in response to @BvU in post #9.
Absolutely, @MevsEinstein I hope you have learned your lesson here.

jbriggs444 said:
One would expect this sequence to converge to ... 30, 30, 30, 30, ... with a few 20, 10 and 10, 20 subsequences scattered therein.
Er... actually it will converge to ... 10, 10, 10, ... with a few 20's and 30's scattered in (we are looking at intervals between composites which become increasingly dense).
 
  • Like
Likes jbriggs444
  • #51
jbriggs444 said:
One would expect this sequence to converge to ... 30, 30, 30, 30, ... with a few 20, 10 and 10, 20 subsequences scattered therein.

pbuk said:
Er... actually it will converge to ... 10, 10, 10, ... with a few 20's and 30's scattered in (we are looking at intervals between composites which become increasingly dense).
Doesn’t throwing in a few other numbers mean that the sequence does not converge?
 
  • #52
phinds said:
Your table is linear.
Strictly speaking, the data suggest a piecewise linear graph, which is somewhat different.
phinds said:
Of course, but the data does not support a pure straight line.
Right.
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K