What function satisfies this table?

In summary, @BvU found an approximation for the cosine function that is better than the one I found. @BvU got the variables he needed from wolfram alpha.
  • #1
MevsEinstein
124
36
TL;DR Summary
I have a data set where the y values oscillate like a trig function, but not exactly.
I have a table of values (from my own analysis, not from a textbook) that represents a portion of a periodic function:
xy
030
120
210
310
420
530
What function satisfies the table? What I know is that the function is periodic. I was thinking I could use cosine because its maximum is at x=0.
 
Last edited:
Mathematics news on Phys.org
  • #2
Hi,
You want to make a plot of your data and then think again ...

##\ ##
 
  • Like
Likes yucheng, hmmm27, mfb and 2 others
  • #3
Your table is linear. Cos is not linear. As bvu said, think again.
 
  • #4
phinds said:
Your table is linear
Y is oscillating up and down though.
 
  • #5
Did you make the plot ?
 
  • #7
And you STILL think it's a function of cos ?
MevsEinstein said:
Y is oscillating up and down though.
No, it is linearly down, then linearly up, not up down up down up down which is what oscillating describes. Some kind of ABS function, probably including a MOD 3 in there somewhere.
 
  • #8
Correct but doesn't win the beauty prize.
1655420522538.png


One can fit a ##\cos (ax+b) + c ## through this. Or a ##\cos^2## if you want.
Do you know how to do that ?

##\ ##
 
  • Like
Likes Delta2, Lord Jestocost, jbriggs444 and 1 other person
  • #9
MevsEinstein said:
Summary: What the title says That is not a summary !

I know that it is periodic
Then you know more than we do. Can you explain ?

##\ ##
 
  • Like
Likes jbriggs444
  • #10
BvU said:
Correct but doesn't win the beauty prize.
View attachment 302932

One can fit a ##\cos (ax+b) + c ## through this. Or a ##\cos^2## if you want.
Do you know how to do that ?

##\ ##
I meant that cos could approximate it. The triangle wave can help, but I don't know how to shift and resize it to fit the graph.
 
  • #11
BvU said:
Can you explain?
The plot is only a portion of the whole function. I will edit the OP.
 
  • #12
MevsEinstein said:
The plot is only a portion of the whole function
You still know more than we do.

And you haven't answered
BvU said:
Do you know how to do that ?
 
  • #13
##d\cos(ax+b)+c\ \ ## fits your data almost exactly when
a = 1.047186112 (##=\pi/3)##
b = 0.523625592
c = 20.00008882
d = 11.547076

1655422325145.png
 
  • Like
Likes Delta2 and Lord Jestocost
  • #14
MevsEinstein said:
The plot is only a portion of the whole function. I will edit the OP.
That is generally a bad way to handle this. When you discover that the OP of yours was confusing and want to add more information, it is much better to add a new reply with the improved information. When you edit your OP with new information, it confuses anybody who comes into the thread and sees all the questions about confusing data... Just sayin' :smile:
 
  • Like
Likes yucheng, PhDeezNutz, Vanadium 50 and 1 other person
  • #15
berkeman said:
That is generally a bad way to handle this. When you discover that the OP of yours was confusing and want to add more information, it is much better to add a new reply with the improved information. When you edit your OP with new information, it confuses anybody who comes into the thread and sees all the questions about confusing data... Just sayin' :smile:
Oh okay thanks for the advice.
 
  • Like
Likes berkeman
  • #16
BvU said:
##d\cos(ax+b)+c\ \ ## fits your data almost exactly when
a = 1.047186112 (##=\pi/3)##
b = 0.523625592
c = 20.00008882
d = 11.547076

View attachment 302934
Where do you get these values from? Also, I set the amplitude as 15, The period as 5, the side shift as zero, and the y shift as 15. It makes a good approximation of the four top points but misses the bottom ones.
 
  • #17
@BvU d is a good approximation of ##\frac{20}{\sqrt{3}}##. b is ##\frac{9763\pi}{58575}##. c is 60*Q + 800/49, where Q is the QRS constant. I got these from wolfram alpha by just entering the values and seeing which approximation is closest.
 
  • #18
MevsEinstein said:
Where do you get these values from?
I would guess that he imagined that ##y = d\cos(ax + b) + c## would be a reasonable fitting curve. By using the points you gave it looks like he was able to solve for those four parameters.
MevsEinstein said:
Also, I set the amplitude as 15, The period as 5, the side shift as zero, and the y shift as 15. It makes a good approximation of the four top points but misses the bottom ones.
Your amplitude, 15, varies a significant amount from what @BvU calculated. And since your parameterization misses a couple points, it's not as good as the one BvU found.
 
  • Like
Likes SammyS
  • #19
Mark44 said:
And since your parameterization misses a couple points, it's not as good as the one BvU found.
BvU asked me to find the variables before he posted his approximations.
 
  • #20
MevsEinstein said:
BvU asked me to find the variables before he posted his approximations.
It's not relevant that you knew or didn't know the values that BvU got. The clue was that the values you found made it so that your function didn't go through or close to all of the given points.
 
  • #21
MevsEinstein said:
Where do you get these values from?
We are trying to fit ##y = d\cos(ax + b) + c##

Those four parameters are:

Vertical scale: d
Vertical offset: c
Frequency offset: a
Phase offset: b

The way I would have obtained the values would be to start with the symmetries in the data. BVU's graph is a thing of beauty to work from for that purpose. It displays graphically the picture that should be in one's head. [My mind's eye would have tried a simpler fit to an absolute value function, but I can squint and see a cosine instead]

The horizontal midpoint is at y=20 exactly. So we can immediately take the vertical offset ##c=20##.

Now look at the values for x=1 and x=4. Those are both on the zero line of the graph of cosine. So those are one half cycle apart (could also be 1.5 cycles or 2.5, etc, but we'll not go there). From that we get that the frequency shift ##a=\frac{\pi}{3} = 1.04719755##.

The vertical midpoint is at x=2.5 exactly. You want a minimum of the cosine result there. So it would be convenient to take ##ax+b = \pi## at ##x = 2.5##. But I do not want to do things that way...

Consider that ##d## will be negative and and taken ##ax+b = 0## at ##x = 2.5##. We already have ##a = \frac{\pi}{3}## so we can solve for ##b## and get that the phase offset ##b = -\frac{5\pi}{6} = 2.6179938##

Now all we have to do is figure out the vertical scale ##d##. If you look at the data values for x=2 or x=3 compared to a center line at x=2.5, both of those are 1/3 of the way through a quarter cycle of the cosine function. So they correspond to the cosine of ##\frac{\pi}{6}##. We already have the vertical offset (##c = 20##) and want to solve for the vertical scale (##d##). We have the given data ##y=10## for both ##x## values.

So we want ##d \cos \frac{\pi}{6} + 20 = 10##. We can solve this and obtain. ##d = \frac{-10}{cos (\pi/6)} = -19.098593##

[Note that ##d## came out negative just as we wanted because we chose to center our cosine on ##x=2.5##]

If I haven't muffed some arithmetic or algebra along the way, all of this (except the decimal values, of course) should be exact.
 
Last edited:
  • Like
Likes SammyS, mfb and OmCheeto
  • #22
This entire thread, other than the original problem statement, has been about finding a best fit. My read of the original problem is that it does not ASK for a best fit, it asks for a function. I don't get how that can be interpreted as anything other than an EXACT function, not an approximation. See my posts #3 and #7.

With exactly the data set provided, the exact function is this

f(x) = 10 * (1 + floor(abs(2.5-x)))

The OP even recognizes that this is the kind of function needed when he mentions triangular function in post#11
 
  • Like
Likes PhDeezNutz
  • #23
phinds said:
With exactly the data set provided, the exact function is this
To be clear, that is an exact function, not the exact function.

Edit: Though William of Occam might offer some helpful advice about which function is intended.
 
  • Like
Likes mfb and phinds
  • #24
jbriggs444 said:
To be clear, that is an exact function, not the exact function.
Good point. Still, it IS an exact function, not an approximation like all the cos stuff so the main point I was making still stands.
 
  • #25
phinds said:
Good point. Still, it IS an exact function, not an approximation like all the cos stuff so the main point I was making still stands.
The cos stuff yields a whole family of exact matches as well. And one can always do an exact match with an interpolating polynomial.

Personally, I'd have dropped the floor function from the absolute value formula. That would yield yet another exact match.
 
  • #26
jbriggs444 said:
The cos stuff yields a whole family of exact matches as well. And one can always do an exact match with an interpolating polynomial.
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.
 
  • Like
Likes jbriggs444
  • #27
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.
The decimals are rounded, yes. Those are approximations. But I gave explicit results in terms of ##\pi## which are exact in #21. [Even if I bungled the algebra or arithmetic there, it is clear that a family of exact solutions in that form with closed form values for the four parameters exist]
 
  • Like
Likes phinds
  • #28
But the cos function solution would not hold if the rest of the linear points were put in. Such as f(3.5) = 15 and f(4.5) = 25

I admit that my mind got immediately stuck on the triangle function and that the graph is segmented linear and, assuming that it is, cannot be represented by a cos function, so I rejected the cos function out of hand and wondered why everyone was focused on it instead of an exact solution ("exact" of course requiring the same assumption I made, which is that the function IS piece-wise linear, which seemed to be confirmed by the OP's statement about the triangle function).
 
  • Like
Likes jbriggs444
  • #29
phinds said:
But the cos function solution would not hold if the rest of the linear points were put in. Such as f(3.5) = 15 and f(4.5) = 25

I admit that my mind got immediately stuck on the triangle function and that the graph is segmented linear and, assuming that it is, cannot be represented by a cos function, so I rejected the cos function out of hand and wondered why everyone was focused on it instead of an exact solution ("exact" of course requiring the same assumption I made, which is that the function IS piece-wise linear, which seemed to be confirmed by the OP's statement about the triangle function).
At first glance, post #8 by @BvU indeed looked wrong-headed. But then on second thought it seemed like a master stroke -- an opportunity to pursue a solution that matched what the original poster had in mind without giving away the solution that the problem's author intended. A solution that could even be exact. And all one had to do was to interpolate from the given data points in the simplest manner possible.

Tasty!
 
  • #30
jbriggs444 said:
And all one had to do was to interpolate from the given data points in the simplest manner possible.
Hm ... I thought MY interpretation was the simplest possible :smile:
 
  • #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.
 
  • #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:
<h2>1. What is the purpose of finding a function that satisfies a table?</h2><p>Finding a function that satisfies a table allows us to make predictions and analyze patterns in the data represented by the table. It also helps us to understand the relationship between the input and output values in the table.</p><h2>2. How do you determine the function that satisfies a given table?</h2><p>To determine the function that satisfies a table, we need to first look at the input and output values in the table and determine the pattern or relationship between them. Then, we can use this pattern to write an equation or formula that represents the function.</p><h2>3. Can there be more than one function that satisfies a given table?</h2><p>Yes, there can be multiple functions that satisfy a given table. However, the most common approach is to find the simplest function that fits the data, which is usually the linear or polynomial function with the lowest degree.</p><h2>4. What are some methods for finding a function that satisfies a table?</h2><p>Some methods for finding a function that satisfies a table include using algebraic techniques such as substitution and elimination, graphing the data and looking for a pattern, and using technology such as regression analysis.</p><h2>5. How can we verify if a function satisfies a given table?</h2><p>We can verify if a function satisfies a given table by plugging in the input values into the function and comparing the output values to the ones in the table. If they match, then the function satisfies the table. Additionally, we can also graph the function and see if it passes through the points in the table.</p>

1. What is the purpose of finding a function that satisfies a table?

Finding a function that satisfies a table allows us to make predictions and analyze patterns in the data represented by the table. It also helps us to understand the relationship between the input and output values in the table.

2. How do you determine the function that satisfies a given table?

To determine the function that satisfies a table, we need to first look at the input and output values in the table and determine the pattern or relationship between them. Then, we can use this pattern to write an equation or formula that represents the function.

3. Can there be more than one function that satisfies a given table?

Yes, there can be multiple functions that satisfy a given table. However, the most common approach is to find the simplest function that fits the data, which is usually the linear or polynomial function with the lowest degree.

4. What are some methods for finding a function that satisfies a table?

Some methods for finding a function that satisfies a table include using algebraic techniques such as substitution and elimination, graphing the data and looking for a pattern, and using technology such as regression analysis.

5. How can we verify if a function satisfies a given table?

We can verify if a function satisfies a given table by plugging in the input values into the function and comparing the output values to the ones in the table. If they match, then the function satisfies the table. Additionally, we can also graph the function and see if it passes through the points in the table.

Similar threads

  • General Math
Replies
11
Views
1K
Replies
5
Views
788
  • General Math
Replies
15
Views
2K
Replies
17
Views
2K
  • General Math
Replies
6
Views
1K
Replies
2
Views
777
Replies
1
Views
621
Replies
3
Views
693
Replies
7
Views
925
Replies
2
Views
628
Back
Top