What function satisfies this table?

Click For Summary

Discussion Overview

The discussion revolves around identifying a function that satisfies a given table of values representing a periodic function. Participants explore various mathematical models and approaches, including cosine functions and piecewise definitions, while debating the nature of the function based on the provided data.

Discussion Character

  • Exploratory
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants suggest that a cosine function could model the periodic nature of the data, while others argue that the data does not exhibit the expected oscillatory behavior of a cosine function.
  • One participant proposes that the function could be approximated using a cosine function with specific parameters, while another suggests that an absolute value function might be more appropriate.
  • There are discussions about fitting parameters for a cosine function, including amplitude, frequency, phase, and vertical offset, with varying degrees of success noted by participants.
  • Some participants emphasize the need for an exact function rather than an approximation, suggesting that the original problem implies a requirement for a precise mathematical representation of the data.
  • Disagreement exists regarding the interpretation of the original problem, with some insisting that it asks for an exact function while others focus on finding the best fit.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the nature of the function that satisfies the table. There are multiple competing views on whether a cosine function or an exact piecewise function is more appropriate, and the discussion remains unresolved.

Contextual Notes

Participants express uncertainty regarding the exact nature of the function, with some arguing for approximations and others for exact representations. The discussion highlights the complexities involved in fitting functions to data and the potential for multiple valid interpretations.

MevsEinstein
Messages
124
Reaction score
36
TL;DR
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
Hi,
You want to make a plot of your data and then think again ...

##\ ##
 
  • Like
Likes   Reactions: yucheng, hmmm27, mfb and 2 others
Your table is linear. Cos is not linear. As bvu said, think again.
 
phinds said:
Your table is linear
Y is oscillating up and down though.
 
Did you make the plot ?
 
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.
 
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   Reactions: Delta2, Lord Jestocost, jbriggs444 and 1 other person
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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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:
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 10 ·
Replies
10
Views
6K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K