Approximating Sin() Graph: Discussion & Equation

  • Context: Undergrad 
  • Thread starter Thread starter STAii
  • Start date Start date
  • Tags Tags
    Sin
Click For Summary

Discussion Overview

The discussion revolves around an equation proposed by a participant that approximates the graph of the sine function, y = Sin(x). Participants explore the derivation of this equation, its graphical behavior, and its relationship to simple harmonic motion and projectile motion. The conversation includes technical reasoning, mathematical exploration, and conceptual clarifications.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant presents an equation intended to approximate the sine function and invites feedback on its validity.
  • Another participant questions the accuracy of the equation at specific points, such as x = pi/2, suggesting a potential error in calculations.
  • A different participant agrees with the initial equation's approximation to sin(x) after correcting a numerical mistake.
  • One participant describes their thought process in developing the equation, linking it to concepts of simple harmonic motion and projectile motion.
  • Another participant suggests that the sine function can be approximated by a quadratic function near zero, referencing Taylor series expansion.
  • Concerns are raised about the use of the integer function versus the floor function in the equation, with suggestions for correcting potential anomalies in the function's behavior.
  • Participants discuss the complexity of the proposed approximation and alternative methods, such as using table look-ups for computational efficiency.

Areas of Agreement / Disagreement

Participants express differing views on the accuracy and complexity of the proposed approximation. While some acknowledge its merits, others raise concerns about its practical implementation and mathematical correctness. The discussion remains unresolved regarding the best approach to approximating the sine function.

Contextual Notes

There are unresolved issues regarding the definitions of the integer function and its implications for the equation's behavior across different intervals. Participants also note potential discrepancies in the calculations and the need for clarification on the mathematical operations involved.

STAii
Messages
327
Reaction score
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
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.
 
?

For x= pi/2, this formula gives y= -1/2. Doesn't look like sin(x) to me.
 
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 !
 
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
 
Well, you're right about pi/2: I wrote a number down wrong.


This really is a very nice approximation to sin(x).
 
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:
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...:)
 
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K