Approximating Sin() Graph: Discussion & Equation

  • Thread starter STAii
  • Start date
  • Tags
    Sin
In summary, the conversation discusses an equation that approximates the graph of y=sin(x) and how it was derived. The equation includes the use of the integer and floor functions, as well as the pi symbol representing the constant ratio of the circumference of a circle to its diameter. The conversation also touches on the use of the floor function versus the integer part function.
  • #1
STAii
333
1
Greetings !
The other day i was fooling around a little with equations, i came up with an equation that (when graphed) look very similar to the graph of y=Sin() .
Tell me what you think, and if anyone cares to know how i came up with it, i will tell.
y = -1[ x/π ]((-4x2/π2) + (x/π)(8[ x/π ] + 4) - 4[ x/π ]([ x/π ] + 1))
Note that [ x ] means the integer of x.
Edit :
π is supposed to be [pi], i don't know why it looks so ugly !
 
Last edited:
Mathematics news on Phys.org
  • #2
Yes, tell us, how did you come up with it? For what values of x does it work for?

The pi symbol looks ugly because its capitol pi.
 
  • #3
?

For x= pi/2, this formula gives y= -1/2. Doesn't look like sin(x) to me.
 
  • #4
Actually, the graph is 100% right at n[pi]/2 (where n in an integer), it seems you have a mistake somewhere.
Let me demonstrate when x = pi/2
x/pi = pi/2pi = 1/2
[ x/pi ] = [ pi/2pi ] = [ 1/2 ] = 0
x2/pi2 = pi2/4pi2 = 1/4
So :
y = -10((-4*0.25) + 0.5*(0*8 + 4) + 4*0*(0+1))
y = 1*(-1 + 0.5*(0 + 4) + 0)
y = -1 + 4/2
y = -1 + 2
y = 1

I wonder how you got -1/2 ...

I will tell you how i came up with it, but i unfortunately have no time now, some time soon i will post it here.

Thanks !
 
  • #5
Ok, i thought a second about it, maybe saying the [ x ] is the integer of x was misleading.
What i mean by [ x ] is :
[ x ] = n , where n in a certain integer that satisfy :
n <= x < n+1
 
  • #6
Well, you're right about pi/2: I wrote a number down wrong.


This really is a very nice approximation to sin(x).
 
  • #7
Ok, so now that i have time, i will write down how i came up with the idea.
It was while i was preparing for my physics exam (i never read the textbook before, this was my first time ), one of the chapters in our textbook talks about simply harmonic motion.
Now, a simply harmonic motion (sorry if the naming is wrong, but you know it hard to get the right word in English), the force must always be in opposite direction of displacement, and must be proportional to distance between the object and the point of equilibrum.
At that point, i tried to think, what is the different between the simple harmonic motion in half a cycle, and the motion of an object in ballestic trajectory (ignoring air resistance).
I tried to think, i reached the conclusion that it must be something related to in which part of the motion the biggest part of change in speed happen.
I thought, a graph would make everything clearer, so, i tried to graph the motion of a balestic (moving upwards) and simply harmonic motion in half a cycle (distance versus time graph), with the same heighest point, and the same time interval.
As we know, the motion of an object moving upwards under the effect of gravity in a distance versus time graph is actually a parabola (not sure of the naming, but it can be written as ax2+bx+c).
So, i took 3 test points, to make my two graphs.
(0,0)
(&pi;/2,1)
(&pi;,0)
So, i made a function, called f(x), defined on the interval [0,&pi;]
f(x)=ax2+bx+c
f(0)=0
f(&pi;/2)=1
f(&pi;)=0
I then solved to get the values of a,b and c.
from the first equation, c=0
from third equation, a=-b/&pi;
solve with second equation, b=4/&pi;
and, a=-4/&pi;2
Now, i graphed my f(x) on [0,&pi;] and sin(x) on the same interval, they looked very similar (and i was able to figure out the difference between the two types of motion).
My next step, to make my f(x) the same as cos(x) on other intevals.
Now, on the interval [&pi;,2&pi;] is the same as on [0,&pi;], except it will be shifted &pi; to the right, and it will be inverted (or, in other words, multiplied by -1).
So, on the interval [&pi;,2&pi;] -f(x-&pi;) will almost match sin(x) on the same interval, and so on ...
Now, i needed a way to the -&pi; jumps each time x gets &pi; bigger.
I thought, if i found an integer that gets bigger by 1 each time x gets &pi; bigger, i will only need to multiply it by &pi;.
And [ x/&pi; ] is what i needed, this function gets bigger by 1 each time x gets bigger by &pi; (and on steps).
So, the function f(x-&pi;[ x /&pi; ]) is almost what we need, it oscilates, and a new half cycle starts every n&pi;, the only problem is getting it up and down.
We need it up when x is in [ 2n&pi;, 2n&pi; + &pi;] and down when x is in [ 2n&pi; + &pi;, 2n&pi; + 2&pi; ].
I have been taught the trick of -1n (yes, i was taught it, this is the only thing that i didn't think of), when n is odd the result is -1, when n is even the result is 1.
So, my last function was -1[ x/&pi; ]f(x-&pi;[ x/&pi; ]), where f(x) = ax2+bx+c, and a=-4/&pi;2, b=4/&pi; , c=0.
The version of the equation you see in my first post is a simplified one.
If you have any questions or comment, please feel free to tell them :smile:.
Thanks for your time all.
 
Last edited:
  • #8
Well...it uses the fact that sin(x) can be approximated by a a*x^2+b*x+c function in the vecinity of 0...taylor...the rest is very clever...:)
 
  • #9
I commend you on the way you came up with a good approximation to sin(x), even if it tends to more complexity than less. From a practical perspective, i'd just use a table look-up (computers often implement the function this way when they need speed).

But I wanted to comment that you should be using the FLOOR function instead of the INTEGER_PART function.

For example:
[-x/pi] = -[x/pi] or for all x

Which means that from (-pi, 0) your function f(x) is not shifted at all (shift factor of [x/pi] is 0). So the value -pi < x < 0 is plugged into the original function f(x). Using floor will fix this anomaly.

edit: removed link
 
Last edited by a moderator:
  • #10
Well, maybe the way i named the function (i called it Integer function) was wrong, but i think i corrected this in previous post, when i said :
What i mean by [ x ] is :
[ x ] = n , where n in a certain integer that satisfy :
n <= x < n+1
According to this definition, when x is in (-pi,0) then [ x/pi ] = -1, which makes the shift to the left.
Right ? (maybe i am missing sth).

EDIT :
Thanks suffian for the graph, and thanks all for your time.
Suffian, you are right, the function makes the whole thing more complicated, but it was fun making it :wink:
 
Last edited:
  • #11
Well, maybe the way i named the function (i called it Integer function) was wrong, but i think i corrected this in previous post, [...]
oh, sorry, i didn't see that part.
 

1. What is the equation for approximating the Sin() graph?

The equation for approximating the Sin() graph is y = a*sin(bx + c) + d. The 'a' value represents the amplitude, 'b' represents the period, 'c' represents the phase shift, and 'd' represents the vertical shift.

2. How do you determine the amplitude of the Sin() graph?

The amplitude of the Sin() graph is determined by the value of 'a' in the equation. It represents the maximum vertical distance between the graph and the x-axis.

3. What is the period of the Sin() graph?

The period of the Sin() graph is determined by the value of 'b' in the equation. It represents the horizontal length of one cycle of the graph.

4. How do you calculate the phase shift of the Sin() graph?

The phase shift of the Sin() graph is determined by the value of 'c' in the equation. It represents the horizontal shift of the graph from its original position.

5. What is the purpose of approximating the Sin() graph?

The purpose of approximating the Sin() graph is to simplify and generalize the graph, making it easier to work with in mathematical calculations and applications.

Similar threads

  • General Math
Replies
2
Views
631
  • General Math
Replies
2
Views
718
  • General Math
Replies
7
Views
949
Replies
1
Views
661
Replies
4
Views
400
  • General Math
Replies
3
Views
1K
Replies
6
Views
923
Replies
5
Views
946
Replies
5
Views
2K
Replies
5
Views
843
Back
Top