473,569 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to determine a point on a sine wave

Hi,

I'm trying to do get my head around some, probably basic, math
calculations. I checked some .net math libs, but the only thing I learn
from studying those is humility ;-).

Anyway, i have an array of points on a basic 2 dimensional axis. They
are all points of a sine shaped line. (not a perfect sine though, as
it's actually tide movement data that is roughly looking as a sine).

I would like to calculate the y dimension for a point with a known x value.

Can anyone help me solve this issue or give a pointer in the right
direction by providing some of the math slang for this problem?

Regards,

MathNewbie
Oct 24 '06 #1
5 8806
MathNewbie,

If I understand your question, you're trying to find the y value of a
point on a sinusoidal curve at a given x. That's simple: y = sin x. Use
Math.Sin().

If you know the y value already and you're trying to find the x value,
you need an arcsin: x = arcsin y. Use Math.Asin(). Bear in mind that
sinusiods are repeating, so you're going to get the first x value at
which the y value exists. Add 2*pi to get the second, 4*pi to get the
third, and so on.

I should note that everything from Math.[any trig function] will give
you radians, not degrees. If you're working with a high school
education, the information that 2*pi radians = 360 degrees will bridge
the gap.

HTH!

Stephan


MathNewbie wrote:
Hi,

I'm trying to do get my head around some, probably basic, math
calculations. I checked some .net math libs, but the only thing I learn
from studying those is humility ;-).

Anyway, i have an array of points on a basic 2 dimensional axis. They
are all points of a sine shaped line. (not a perfect sine though, as
it's actually tide movement data that is roughly looking as a sine).

I would like to calculate the y dimension for a point with a known x value.

Can anyone help me solve this issue or give a pointer in the right
direction by providing some of the math slang for this problem?

Regards,

MathNewbie
Oct 24 '06 #2
this any use ?
http://users.rowan.edu/~shreek/networks1/music.html
"MathNewbie " <ma********@exa mple.orgwrote in message
news:45******** *************@n ews.xs4all.nl.. .
Hi,

I'm trying to do get my head around some, probably basic, math
calculations. I checked some .net math libs, but the only thing I learn
from studying those is humility ;-).

Anyway, i have an array of points on a basic 2 dimensional axis. They are
all points of a sine shaped line. (not a perfect sine though, as it's
actually tide movement data that is roughly looking as a sine).

I would like to calculate the y dimension for a point with a known x
value.

Can anyone help me solve this issue or give a pointer in the right
direction by providing some of the math slang for this problem?

Regards,

MathNewbie


Oct 24 '06 #3
"MathNewbie " <ma********@exa mple.orgwrote in message
news:45******** *************@n ews.xs4all.nl.. .
[...]
Anyway, i have an array of points on a basic 2 dimensional axis. They are
all points of a sine shaped line. (not a perfect sine though, as it's
actually tide movement data that is roughly looking as a sine).

I would like to calculate the y dimension for a point with a known x
value.
If the points are sorted on the x coordinate, this is not hard at all. For
x where x is actually in your data set, it's simply a matter of looping
through the array to find x. With a sorted array, you can use a binary
search to more quickly find the point of interest.

If the x value does not actually correspond to one of the points within the
array, then you'll have to interpolate the value from one of the known
values. You'll still have to search, but rather than finding the exact
match, you'll find a pair of points in the array, between which that x value
would be found. Once you've done that, you apply the ratio of the desired x
to the interval between the x values of the two known points, to the
interval between the y values of the two known points, to find the desired y
value.

For example:

Suppose you have the set describing f(x) as { {0, 0}, {2, 3}, {4, 5}, {6,
8} }
(yes, I'm aware that's not a sine wave :) )

Suppose also that you want y = f(x) where x is 3. Searching through your
array, you fail to find an entry where x is 3, but you do find the entries
{2, 3} and {4, 5}. Call these {x0, y0} and {x1, y1}. Then...

y = y0 + (y1 - y0) * (x - x0) / (x1 - x0);

In the specific example:

y = 3 + (5 - 3) * (3 - 2) / (4 - 2)
= 3 + 2 * 1 / 2 = 4;
Can anyone help me solve this issue or give a pointer in the right
direction by providing some of the math slang for this problem?
"Interpolat ion" is the math buzz word that applies to your question. But
hopefully the above gives you the details you need.

Note that x needs to be within the range of known x values (or you have to
"extrapolat e" off each end), and this does not guarantee a perfect match to
the curve that may represent your data. This is a linear interpolation, so
between each known point, the interpolated points fall on a straight line.
Since the actual data is curved, this means that the calculated value will
deviate from the correct value by some (usually small) amount. The error is
greatest when the desired value is farthest from either end of the
interpolation range.

If you want more accurate results, you will have to use more complex forms
of interpolation. Another common method is "polynomial approximation",
where you solve a large matrix of equations (one for each data point you
have) to establish constants and exponents to whatever degree you want. Yet
another method would involve fitting a sin function to subsets of your data,
allowing you to use an interpolated sin approximation of the function.

Of course, in all cases you are not guaranteed to have an exactly correct
answer. Any time you are filling in data that is absent from actual
empirical recordings, you have no way to know for sure that you have
interpolated the correct data. All you can say is that you have
interpolated a relatively useful simile of the correct data.

Pete
Oct 24 '06 #4
On Tue, 24 Oct 2006 20:55:03 +0200, MathNewbie
<ma********@exa mple.orgwrote:
>Hi,

I'm trying to do get my head around some, probably basic, math
calculations . I checked some .net math libs, but the only thing I learn
from studying those is humility ;-).

Anyway, i have an array of points on a basic 2 dimensional axis. They
are all points of a sine shaped line. (not a perfect sine though, as
it's actually tide movement data that is roughly looking as a sine).

I would like to calculate the y dimension for a point with a known x value.

Can anyone help me solve this issue or give a pointer in the right
direction by providing some of the math slang for this problem?
If I understand correctly, you want to be able to extrapolate the Y
position on a graph, based on a notional X position between two
existing X points. Assuming that the "dots" on the graph are joined by
straight lines, you can use something like the following (apologies
for the rather silly variable names):

public static double Extrapolate_Lin ear(double Value, double InMin,
double InMax, double OutMin, double OutMax)
{
double InRange, OutRange;
double Val;
double Result;

InRange = InMax - InMin;
OutRange = OutMax - OutMin;
Val = Value - InMin;

Result = Val / InRange * OutRange + OutMin;

return (Result);
}

So, for instance, if you have two XY points (4,10) and (7,15), and you
wanted to know the Y value corresponding to an X value of 5, calling

Whatever = Extrapolate_Lin ear (5, 4, 7, 10, 15);

would give you 11.667

--
Posted via a free Usenet account from http://www.teranews.com

Oct 25 '06 #5
Thank you all for your suggestions. I'll give them a try!

Regards,

MathNewbie
Oct 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12690
by: Xanax | last post by:
Hi all, I need to produce a sine wave and use the WaveOut APi to sound it on my sound card. I also need to compute Fast Fourier Transform to modify the Sine wave. Any ideas on where to start or get some info on this?? Cheers, Xanax.
11
12012
by: Phil Newman | last post by:
I'm trying to implement a basic sinewave signal using arrays, but I'm having difficulty (I'm a complete beginner!) This is what I have so far: using namespace std; double signal(double sinewave, double x); int main()
143
7952
by: suri | last post by:
Hello I downloaded glibc and tried looking for the code that implements the sine function i couldnt find the file. i went to the math directory and found math.h.. i guess that needs to be included for the sine function. but which .c file implements the sine/cosine and other trig fns thanks
10
3084
by: Owkmann | last post by:
Can someone give me a rough idea how a value is obtained for a trigonometric function like Math.Sin? What is the algorithm? I'm finding that putting a large number in this function ( > 8000 ) really slows things down. Why is that? Thanks, Owkmann
8
12708
by: mcenley | last post by:
can any one please help me in creatind a sine wave in C++ please i also need to play it as a .wav file any random sound within sudible frequency will do
5
6203
by: RayD | last post by:
I'm looking for a simple program or method to generate sine waves or square waves at a desired frequency. Thanks for your help Ray
5
11236
by: MandaRonnie | last post by:
I have an assignment im working on for my computer science class (c programming). My program compiles right, but doesn't run like its suppose to. Could someone help me? Here is the assignment: The value of sin(x) can be approximated by using the formula: sin(x) = x −x3/3!+x5/5!−x7/7!+x9/9!· · · where x is an angle in radians. Using...
7
3094
by: company1484 | last post by:
I've been given an assignment to approximate the value of sine of an angle in degrees by using the formula: sin(x) = x −x3/3!+x5/5!−x7/7!+x9/9!· · · x is an angle in radians. He wants the program outline to be like so: 1 read in a new value for angle 2 while(angle != 0){ 3 convert angle to radians (multiply angle by pi/ 180 ) 4 sine = 0...
4
6819
by: Iain Mackay | last post by:
Python Folks I'm a newbie to Python and am looking for a library / function that can help me fit a 1D data vector to a sine wave. I know the frequency of the wave, so its really only phase and amplitude information I need. I can't find anything in the most widely known libraries (they seem to be strong on polynomial fitting, but not,...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.